我尝试在 QEMU 上运行 VM,但 VM 已启动,但没有与eth0
.我在主机上配置了桥接和分接接口,我可以看到:
brctl show bro
bridge name bridge id STP enabled interfaces
bro 8000.bedc8d16e7d8 no eno1
tap0
界面看起来不错:
ip addr show bro
3: bro: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether be:dc:8d:16:e7:d8 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.112/24 brd 192.168.100.255 scope global dynamic bro
valid_lft 540129sec preferred_lft 540129sec
inet6 fe80::bcdc:8dff:fe16:e7d8/64 scope link
valid_lft forever preferred_lft forever
ip addr show eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bro state UP group default qlen 1000
link/ether 98:90:96:9d:d9:83 brd ff:ff:ff:ff:ff:ff
ip addr show tap0
8: tap0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel master bro state DOWN group default qlen 1000
link/ether d2:74:5b:04:81:f8 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.222/24 brd 192.168.100.255 scope global tap0
valid_lft forever preferred_lft forever
这是我用来运行虚拟机的命令:
sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=CentOS-7-aarch64-Minimal-1810.iso,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=bc:dc:8d:16:e7:d8, -hda centos7-arm.img
在来宾上没有 IP,即使 DHCP 没有:
[root@localhost ~]# ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether bc:dc:8d:16:e7:d8 brd ff:ff:ff:ff:ff:ff
当我尝试从 CentOS 进行配置后nmtui
,service network restart
失败了。在日志中发现:
localhost.localdomain network[4058]: Bringing up interface eth0: Error: Connection activation failed: IP configuration could not be reserved (no available address, timeout, etc.)
您知道可能出了什么问题吗?
答案1
kvm
自从我直接从命令行运行 guest 已经有一段时间了(我更喜欢libvirt
,或者最近的 Proxmox)。
然而,查看主机上的接口定义,并将其与我的工作配置进行比较,最明显的区别是您的tap0
接口有 IP 地址 192.168.100.222/24,而我的接口没有 IP 地址。 (访客定义一个从 DHCP 获取的 IP 地址。主机接口不应有 IP 地址。)
# brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.009c029758d6 no eth0
vnet5
# ip addr show vnet5
12: vnet5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
link/ether fe:54:00:3c:75:33 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe3c:7533/64 scope link
valid_lft forever preferred_lft forever
# ssh vmguest ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:3c:75:33 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.15/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe3c:7533/64 scope link
valid_lft forever preferred_lft forever
该 IP 地址是tap0
您自己设置的,还是您的命令的副作用kvm
?