1. 重启云服务器的网络。

    systemctl restart networking
  2. 离开私有网络,重新加入。

  3. 重启云服务器。

    或者手动更改 DNS 配置,参考格式如下。

    [root@i-tqzv58ti ~]# cat /etc/resolv.conf
    # Generated by NetworkManager
    search localdomain pek3.qingcloud.com
    nameserver 172.20.255.254
  4. 再次验证 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