我们把DNS服务器地址注释掉:
sudo vi /etc/resolv.conf
然后重启网络:
xjtu129@xjtu129-desktop:/etc$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces... Ignoring unknown interface eth1=eth1.
Ignoring unknown interface eth2=eth2.
Ignoring unknown interface ath0=ath0.
Ignoring unknown interface wlan0=wlan0.
[ OK ]
现在我们访问www.xjtu.edu.cn网站,down掉了
我们在添加本地解析:
sudo vi /etc/hosts
添加:
127.0.0.1 localhost
127.0.1.1 xjtu129-desktop
202.117.1.13 www.xjtu.edu.cn //添加

# The following lines are desirable for IPv6 capable hosts

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
现在我们访问www.xjtu.edu.cn一切正常,但其他网站我们还是访问不了
现在我们恢复刚刚的修改
然后:
修改hosts文件,添加:
202.117.1.8 www.xjtu.edu.cn
202.117.1.8是bbs的ip地址,呵呵
然后我们确保一下文件hosts的优先级高于DNS服务器
sudo vi /etc/host.conf
如下;
# The "order" line is only used by old versions of the C library.
order hosts,bind
multi on
ok,我们在访问www.xjtu.edu.cn呵呵,这次进入了bbs网站了







我们在添加本地解析:
















现在我们恢复刚刚的修改
然后:
修改hosts文件,添加:

然后我们确保一下文件hosts的优先级高于DNS服务器



