QEMU桥接模式导致主机网络不通
主机是通过无线网卡上网的。
虚拟机启动后,主机无法上网了。。
配置如下:
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
address 192.168.0.200
network 192.168.0.0
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports enp0s25 tap0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
dns-nameservers 192.168.0.1
$ cat /etc/qemu-ifup
#!/bin/bash
switch=br0
if [ -n "$1" ]; then
ip link set $1 up
sleep 1
brctl addif ${switch} $1
exit 0
else
echo “Error: no interface specified”
exit 1
fi
$ ifconfig
br0 Link encap:Ethernet HWaddr 00:21:cc:5d:29:ee
inet addr:192.168.0.200 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp0s25 Link encap:Ethernet HWaddr 00:21:cc:5d:29:ee
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:20 Memory:f5200000-f5220000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:704 errors:0 dropped:0 overruns:0 frame:0
TX packets:704 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:51468 (51.4 KB) TX bytes:51468 (51.4 KB)
wlp3s0 Link encap:Ethernet HWaddr ec:55:f9:bf:7c:16
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::1d5b:ec79:e83e:f509/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3323 (3.3 KB) TX bytes:8283 (8.2 KB)
虚拟机启动命令:
qemu-system-arm -M vexpress-a9 -m 1024 -smp 4 -kernel ./linux-4.9.13/arch/arm/boot/zImage -sd rootfs.img -append "root=/dev/mmcblk0 rw rootfs=ext4 rootdelay=3 physmap.enabled=0 console=ttyAMA0 console=tty0" -dtb ./linux-4.9.13/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -net nic,vlan=0 -net tap,vlan=0 -nographic