dns配置文件 /etc/resolv.conf中search设置详解

17 篇文章 1 订阅

简介

search swg.local consul.local
nameserver 103.224.222.222

dns配置文件 /etc/resolv.conf 中常看到有search 设置,以前以为是根据search 中的域去指定nameserver,其实不是这样用的。它的一个用处是程序只需要知道主机名就可以解析到ip,不必知道域后缀是什么。下面介绍下设置了search后的解析规则。

FQDN(Fully Qualified Domain Name)含义是完整的域名. 例如, 一台机器主机名(hostname)是www, 域后缀(domain)是baidu.com, 那么该主机的FQDN应该是www.baidu.com. 最后是以"."来结尾的, 但是大部分的应用和服务器都允许忽略最后这个点. 所有大家直接输入 www.baidu.com 也可以识别

解析 shell-server

解析串中无.,先认为是主机名,添加域后缀后查询,查不到再认为其实域名去查询


#host -a shell-server

Trying "shell-server.swg.local"
Trying "shell-server.consul.local"
Trying "shell-server"
Host shell-server not found: 3(NXDOMAIN)
Received 105 bytes from 103.224.222.222#53 in 10 ms

解析 shell-server.nginx

解析串中有.,先以域名查询,查询不到认为是主机名,添加域后缀后查询

# host -a shell-server.nginx
Trying "shell-server.nginx"
Received 111 bytes from 103.224.222.222#53 in 18 ms
Trying "shell-server.nginx.swg.local"
Trying "shell-server.nginx.consul.local"
Host shell-server.nginx.consul.local not found: 5(REFUSED)
Received 49 bytes from 103.224.222.223#53 in 9 ms

解析 shell-server.

解析串以.结尾,认为是完毕域名不自动添加域后缀

# host -a shell-server.

Trying "shell-server"
Received 105 bytes from 103.224.222.222#53 in 2 ms
Trying "shell-server"
Trying "shell-server"
Host shell-server. not found: 3(NXDOMAIN)
Received 105 bytes from 103.224.222.222#53 in 2 ms

参考

https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/networking_guide/sec-using_the_networkmanager_command_line_tool_nmcli
http://dns-learning.twnic.net.tw/bind/intro4.html
https://unix.stackexchange.com/questions/128091/no-domain-defined-in-etc-resolv-conf
https://www.cyberciti.biz/faq/change-dns-ip-address-rhel-redhat-linux/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值