linux下域名解析搜索顺序测试(hosts和dns)

我们把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网站了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值