在具有两个网卡的 ubuntu 18.04 上,一个网卡的 ip 总是无法 ssh 连接

在具有两个网卡的 ubuntu 18.04 上,一个网卡的 ip 总是无法 ssh 连接

我的虚拟机里有两块网卡,虚拟机的操作系统是18.04。

01-network-manager-all.yaml 的内容为:

it@it51:~$ cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: true
      addresses: []
      optional: true
    enp0s31f6:
      dhcp4: no
      addresses: [172.16.11.39/23]
      gateway4: 172.16.10.1
      nameservers:
        addresses: [8.8.8.8]

enp3s0网卡的ip是172.16.10.120

it@it51:~$ ifconfig
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.11.39  netmask 255.255.254.0  broadcast 172.16.11.255
        inet6 fe80::c600:adff:fe38:7cc8  prefixlen 64  scopeid 0x20<link>
        ether c4:00:ad:38:7c:c8  txqueuelen 1000  (Ethernet)
        RX packets 649361  bytes 148866878 (148.8 MB)
        RX errors 0  dropped 284603  overruns 0  frame 0
        TX packets 63476  bytes 6153022 (6.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xdf400000-df420000

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.10.120  netmask 255.255.254.0  broadcast 172.16.11.255
        inet6 fe80::c600:adff:fe38:7cc9  prefixlen 64  scopeid 0x20<link>
        ether c4:00:ad:38:7c:c9  txqueuelen 1000  (Ethernet)
        RX packets 460878  bytes 40248747 (40.2 MB)
        RX errors 0  dropped 284630  overruns 0  frame 0
        TX packets 2964  bytes 336067 (336.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xdf200000-df2fffff

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 329  bytes 29072 (29.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 329  bytes 29072 (29.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

现在我只能通过 ssh 连接到 172.16.11.39,但无法连接到 DHCP 分配的 ip 172.16.10.120。这是什么原因造成的,我该如何修复?

相关内容