完全是新手,厌倦了 Windows 世界,转向了黑暗面
昨天,我通过桥接连接在 VirtualBox 上安装了 Ubuntu 18.4 LTS。
看来我可以在内部 ping 通 IP 地址,在外部 ping 通 IP 地址,但是当我尝试解析主机名或网站时,却无法做到。
rahim@websrv01ubuntu:~$ ping -c3 192.168.0.1PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=3.20 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=9.16 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=7.38 ms
--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 3.206/6.584/9.164/2.497 ms
rahim@websrv01ubuntu:~$ ping -c3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=121 time=34.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=121 time=22.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=121 time=27.8 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 22.980/28.526/34.788/4.849 ms
rahim@websrv01ubuntu:~$ ping -c3 websvr01ubuntu
ping: websvr01ubuntu: Temporary failure in name resolution
rahim@websrv01ubuntu:~$ ping -c3 www.google.com
PING www.google.com(ams16s32-in-x04.1e100.net (2a00:1450:400e:80c::2004)) 56 data bytes
--- www.google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2042ms
50-cloud-init.yaml
我知道 18.04 使用 netplan,这就是文件配置静态 IP 地址的方式。
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.0.200/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
rahim@websrv01ubuntu:~$ ping -c3 google.com
PING google.com(ams16s32-in-x0e.1e100.net (2a00:1450:400e:80c::200e)) 56 data bytes
--- google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2038ms
rahim@websrv01ubuntu:~$ ping -c3 www.google.com
PING www.google.com(ams15s21-in-x04.1e100.net (2a00:1450:400e:800::2004)) 56 data bytes
--- www.google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2034ms
rahim@websrv01ubuntu:~$ ping -c3 www.servingyoubetter.co.uk
PING fwd3.hosts.co.uk (85.233.160.22) 56(84) bytes of data.
--- fwd3.hosts.co.uk ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2055ms
答案1
您的服务器似乎正在尝试使用 IPV6,但配置可能不正确。您可以尝试禁用 ipv6(如果未使用)或检查您的 ipv6 配置。
https://linuxconfig.org/how-to-disable-ipv6-address-on-ubuntu-18-04-bionic-beaver-linux
答案2
查看 olivierb2 的回答。如果仍然不起作用,可能是/etc/resolv.conf
$ sudo mv /etc/resolv.conf /etc/resolv.conf.bak
$ echo nameserver 8.8.8.8 > temp
$ sudo cp temp /etc/resolv.conf