使用内网 DNS 功能
内网dns的使用场景
对 VPC 内部提供域名解析的服务,可以开启/关闭内网 DNS 服务,同时支持开启/关闭 PTR 解析类型-反向 DNS 解析。
1.开启此功能的路径
通过vpc详情界面—管理配置—dns服务—打开dns服务,可以参考截图
2.应用修改vpc网络
3.添加一条内网dns解析,并应用修改vpc网络
4.验证一下配置的内网dns解析是否生效
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.059 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.058 ms
^C
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.030/0.049/0.059/0.013 ms
[root@i-b6s3dvje ~]# ping test
ping: test: Name or service not known
[root@i-b6s3dvje ~]#
5.如内网dns配置没有生效,可以参考以下办法
-
重启云服务器的网络
systemctl restart networking
-
离开私有网络,重新加入
-
重启云服务器
或者手动更改dns配置,参考格式如下
[root@i-tqzv58ti ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain pek3.qingcloud.com
nameserver 172.20.255.254
6.重新验证一下dns配置是否生效
[root@i-b6s3dvje ~]# ping test.localdomain
PING test.localdomain (172.20.100.100) 56(84) bytes of data.
64 bytes from test.localdomain (172.20.100.100): icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from test.localdomain (172.20.100.100): icmp_seq=2 ttl=64 time=0.061 ms
64 bytes from test.localdomain (172.20.100.100): icmp_seq=3 ttl=64 time=0.060 ms
^C
--- test.localdomain ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.027/0.049/0.061/0.016 ms
[root@i-b6s3dvje ~]# ping test
PING test.localdomain (172.20.100.100) 56(84) bytes of data.
64 bytes from test.localdomain (172.20.100.100): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from test.localdomain (172.20.100.100): icmp_seq=2 ttl=64 time=0.057 ms
64 bytes from test.localdomain (172.20.100.100): icmp_seq=3 ttl=64 time=0.097 ms
^C
--- test.localdomain ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.028/0.060/0.097/0.029 ms