Network configuration of debian8.8 real machine

foreword

Experiment on a debian8.8 real machine. After the network is connected, you can ping the ip of other computers, but the domain name cannot be pinged.
The dns server should be set incorrectly. After adding the dns server to /etc/network/bk/interfaces, the domain name still cannot be pinged.
My colleague took a look and found that the dns server specified in resolv.conf is a gateway. After correcting it to a normal dns server, the domain name can be pinged.

experiment

There are 4 files related to Internet access:
/etc/network/bk/interfaces
/etc/nsswitch.conf
/etc/hosts
/etc/resolv.conf
This time the dns information is incorrect, and /etc/network/bk/ interfaces, /etc/resolv.conf

/etc/network/bk/interfaces

# --------------------------------------------------------------------------------
# 修改好的网卡配置 /etc/network/interfaces
# --------------------------------------------------------------------------------
# The loopback network interface
# allow-hotplug eth0 # 需要用ifup启动网络设备
# auto eth0 # 自动启动网卡设备
# 用auto 比 allow-hotplug 好
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 192.168.22.228
    netmask 255.255.240.0
    gateway 192.168.22.1
    dns-nameservers 202.106.196.115
# --------------------------------------------------------------------------------

/etc/resolv.conf

# --------------------------------------------------------------------------------
# 修改好的DNS配置 /etc/resolv.conf
# --------------------------------------------------------------------------------
nameserver 202.106.196.115
# --------------------------------------------------------------------------------

restart the network card

修改好后,可以用xshell重启网络服务
    /etc/init.d/networking restart

    # ifx 只能在真机本地
    ifdown eth0
    ifup eth0

现在ping www.baidu.com是通的

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843353&siteId=291194637