Ubuntu 16.04 无法解析主机名

Ubuntu 16.04 无法解析主机名

我正在尝试让我的 Ubuntu 16.04 OpenStack 实例能够解析 DNS。我刚刚从给定的默认 Ubuntu 映像创建了实例,并正在尝试使用apt-get update我的机器。但是,我收到以下错误消息:

ubuntu@udia-rac:~$ sudo apt-get update
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我有以下 dns.cfg 文件:

$ cat /etc/network/interfaces.d/98-google-dns.cfg
auto lo
iface lo inet loopback
    dns-nameservers 8.8.8.8 8.8.4.4

这将生成我的 /etc/resolv.conf:

ubuntu@udia-rac:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4

当尝试 ping google.com 时,主机无法解析,但直接 ping IP 似乎有效。

ubuntu@udia-rac:~$ ping google.com
ping: unknown host google.com
ubuntu@udia-rac:~$ ping 216.58.216.206
PING 216.58.216.206 (216.58.216.206) 56(84) bytes of data.
64 bytes from 216.58.216.206: icmp_seq=1 ttl=51 time=55.5 ms
64 bytes from 216.58.216.206: icmp_seq=2 ttl=51 time=55.5 ms
64 bytes from 216.58.216.206: icmp_seq=3 ttl=51 time=55.5 ms
^C
--- 216.58.216.206 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 55.532/55.557/55.582/0.193 ms

我尝试重启 resolvconf 服务sudo service resolvconf restart,但问题没有解决。有什么建议吗?

相关内容