Networking QEMU中的网络是如何工作的;什么是来宾操作系统?
我在理解客户操作系统(Ubuntu)中Qemu和网络是如何工作的方面遇到了一个问题。我读过很多书和其他书。如果我理解的话,如果你想在来宾操作系统中接入互联网,你需要在主机操作系统中创建点击接口。然后链接eth0和tap0接口:Networking QEMU中的网络是如何工作的;什么是来宾操作系统?,networking,operating-system,host,qemu,Networking,Operating System,Host,Qemu,我在理解客户操作系统(Ubuntu)中Qemu和网络是如何工作的方面遇到了一个问题。我读过很多书和其他书。如果我理解的话,如果你想在来宾操作系统中接入互联网,你需要在主机操作系统中创建点击接口。然后链接eth0和tap0接口: 通过使用NAT路由 通过使用网桥(链接tap0和eth0主机) 现在我在主机中有了这些接口(ppp0-3G调制解调器-互联网,lo): 阵风OS(eth0,lo)时: 互联网在狂风中工作!若我并没有真实ppp0和客户界面之间的链接,那个么客户操作系统中的网络是如何工作的?
qemu -hda ~/virt.disk -cdrom /dev/cdrom -boot once=dc -m 1024M -usb -smp 2 -enable-kvm
主机路由表:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
default 10.64.64.64 0.0.0.0 UG 0 0 0 ppp0
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 * 255.255.255.0 U 1 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
客人路线表:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
default 10.64.64.64 0.0.0.0 UG 0 0 0 ppp0
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 * 255.255.255.0 U 1 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
看起来您想使用TAP设备,但有问题。 要使用TAP,qemu命令行中应该有如下内容:
-net nic,model=rtl8139 -net tap
在这些参数中,将rtl8139替换为计算机上的任何可用nic设备。如果您不知道可用的nic设备,请使用以下命令列出它们:
qemu -net nic,model=?
您还必须确保已创建TAP设备。以下脚本将创建必要的网桥和端口:
# For Network Bridging/TAP
# Set permissions of tun device
chown root.users /dev/net/tun
chmod g+rw /dev/net/tun
#Add a bridge, add eth0
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc
brctl addif br0 eth0
dhclient br0
# Create tap0
tunctl -t tap0 -u username #replace username by your username
# Enable tap0
brctl addif br0 tap0
ifconfig tap0 up
运行此脚本后,以-net tap参数启动的VM应为网络就绪并使用tap。运行此脚本时,出现以下错误。qemu-system-i386:-网络抽头:无法初始化设备“抽头”