我将服务器从 18.04 升级到 20.04。我使用 libvirt/kvm 托管多个虚拟机。升级后,部分虚拟机无法重新连接到网络。
有问题的两台虚拟机分别运行 Ubuntu 18.04 和 Centos 7,重启后都无法启动网络。在我运行“sudo dhclient”后,两台虚拟机都成功连接
$ ping 1.1.1.1
connect: Network is unreachable
$ sudo dhclient
cmp: EOF on /tmp/tmp.ej3Phm6q0A which is empty
$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=17.7 ms
Centos VM 上“systemctl status network”的输出:
$ sudo systemctl status network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-02-04 08:48:35 UTC; 31min ago
Docs: man:systemd-sysv-generator(8)
Process: 2524 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm network[2524]: RTNETLINK answers: File exists
Feb 04 08:48:35 centosvm systemd[1]: network.service: control process exited, code=exited status=1
Feb 04 08:48:35 centosvm systemd[1]: Failed to start LSB: Bring up/down networking.
Feb 04 08:48:35 centosvm systemd[1]: Unit network.service entered failed state.
Feb 04 08:48:35 centosvm systemd[1]: network.service failed.
在 Ubuntu 18.04 VM 上:
$ sudo systemctl status -l systemd-networkd
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor
Active: active (running) since Tue 2021-02-02 11:23:50 UTC; 1 day 21h ago
Docs: man:systemd-networkd.service(8)
Main PID: 760 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 4915)
CGroup: /system.slice/systemd-networkd.service
└─760 /lib/systemd/systemd-networkd
Feb 04 09:22:10 ******* systemd-networkd[760]: vethf3988ae: Lost carrier
Feb 04 09:22:10 ubuntuvm systemd-networkd[760]: vethf3988ae: Link DOWN
Feb 04 09:22:11 ubuntuvm systemd-networkd[760]: br-32f293377024: Lost carrier
Feb 04 09:23:10 ubuntuvm systemd-networkd[760]: vethf7837d1: Link UP
Feb 04 09:23:11 ubuntuvm systemd-networkd[760]: vethf7837d1: Gained carrier
Feb 04 09:23:11 ubuntuvm systemd-networkd[760]: br-32f293377024: Gained carrier
Feb 04 09:23:12 ubuntuvm systemd-networkd[760]: vethf7837d1: Gained IPv6LL
Feb 04 09:23:12 ubuntuvm systemd-networkd[760]: vethf7837d1: Lost carrier
Feb 04 09:23:12 ubuntuvm systemd-networkd[760]: vethf7837d1: Link DOWN
Feb 04 09:23:13 ubuntuvm systemd-networkd[760]: br-32f293377024: Lost carrier
在 Ubuntu 20.04 主机上:
$ brctl show
bridge name bridge id STP enabled interfaces
...snip...
br0 8000.0cc47a228130 no enp4s0f0
vnet0
vnet1
vnet2
vnet3
vnet5
...snip...
两个虚拟机都设置了连接网桥 br0 的接口:
<interface type='bridge'>
<mac address='52:**********:90'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
为什么主机从 18.04 升级到 20.04 后我的虚拟机无法连接?我该如何解决这个问题?