【Linux】resolv.conf中search作用-创新互联
resolv.conf中的search主要是用来补全hostname的,有时候域名太长,可以做一个短域名做主机名字,但是DNS解析需要的是FQDN,而在resolv.conf中设置search能进行补全。
vim /etc/hosts
42.120.7.71 www
ping www能通,返回就是42.120.7.71,ping会首先解析hosts
vim /etc/resolv.conf
search firefoxbug.net
nameserver 114.114.114.114
这时候nslookup www
Server: 114.114.114.114
Address: 114.114.114.114#53
Non-authoritative
answer:
Name: www.firefoxbug.net
Address: 42.120.7.71
看到没,search的作用就是补全要访问的短域名
正确的域名解析顺序是:
1. 查找/etc/hosts
2. 根据nameserver查找域名
3. 如果在nameserver查找不到域名就进行search补全,重新走1~2步
分享文章:【Linux】resolv.conf中search作用-创新互联
转载来于:http://ybzwz.com/article/djdehc.html