Ubuntu Server - 互联网连接问题,/etc/network/interfaces 为空

Ubuntu Server - 互联网连接问题,/etc/network/interfaces 为空

我管理一台托管一些应用程序的服务器。它在虚拟机上运行,​​我通过 SSH 访问。

操作系统:Ubuntu Server 20.04.1 LTS

一切都运行良好,直到今天,我的脚本无法访问 WAN。(仍然可以通过 SSH 访问)

我可以 ping 出去:

$ ping google.com
PING google.com (216.58.212.206) 56(84) bytes of data.
64 bytes from ams16s21-in-f14.1e100.net (216.58.212.206): icmp_seq=1 ttl=118 time=5.26 ms
64 bytes from ams16s21-in-f14.1e100.net (216.58.212.206): icmp_seq=2 ttl=118 time=5.54 ms

DNS 解析正常:

$ nslookup google.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   google.com
Address: 216.58.212.206
Name:   google.com
Address: 2a00:1450:4009:80a::200e

使用 curl 无法获取任何内容:

$ curl -v https://www.google.com
*   Trying 216.58.212.196:443...
* TCP_NODELAY set
*   Trying 2a00:1450:4009:80a::2004:443...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4009:80a::2004: Network is unreachable
*   Trying 2a00:1450:4009:80a::2004:443...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4009:80a::2004: Network is unreachable

$ ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:15:5d:01:fd:32 brd ff:ff:ff:ff:ff:ff
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 02:42:c2:db:08:92 brd ff:ff:ff:ff:ff:ff

$ ip route list
default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.14 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.14 
192.168.1.1 dev eth0 proto dhcp scope link src 192.168.1.14 metric 100 

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.1     0.0.0.0         255.255.255.255 UH    100    0        0 eth0

$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:c2:db:08:92  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.14  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::215:5dff:fe01:fd32  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:01:fd:32  txqueuelen 1000  (Ethernet)
        RX packets 35862  bytes 5205966 (5.2 MB)
        RX errors 0  dropped 4364  overruns 0  frame 0
        TX packets 3838  bytes 1097697 (1.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8663  bytes 1793628 (1.7 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8663  bytes 1793628 (1.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这可能是一个问题:

$ cat /etc/network/interfaces 

(空的)


$ cat /etc/netplan/*.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    eth0:
      dhcp4: true
  version: 2

非常感谢您的帮助!

相关内容