Setting up tun/tap network doesn't work
Hello.
I'm trying to get qemu 0.7.2 on Gentoo Linux to work with tun/tap network - but fail to do so :/
I compiled the kernel (2.6.13-suspend2-r4) with tun/tap support and copied the "qemu-ifup" script from linux-test-0.5.1 to my /etc directory. I loaded the "tun" module.
alexander@blatt ~/var/qemu $ ls -la /dev/net/tun crw-rw---- 1 root root 10, 200 14. Okt 22:56 /dev/net/tun
When I start qemu (as root) with:
sudo qemu -nographic -hda linux.img -kernel bzImage-2.4.21 -append "console=ttyS0 root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe"
I get as the first line of output:
Connected to host network interface: tun0
and later on:
QEMU Linux test distribution (based on Redhat 9)
Type 'exit' to halt the system
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
sh-2.05b# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 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:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Thus, network isn't setup properly inside the qemu "guest".
Rather obviously, I seem to be missing something. But what is it? Also, the documentation isn't that clear, as far as the network part is concerned... Also, I'm sorry to bother you on the devel list, but the "plain users" forum is down :(
Thanks a lot for any help you can provide,
Alexander Skwar
Hi Alexander,
as I also struggled hard to get qemu networking running, so i will post my notes that i made when i finally managed to get it going. But first a resource that might help you:
faq in the unofficial qemu wiki:
http://lilly.csoft.net/~jeffryj/cgi-bin/moin.cgi/FrequentlyAskedQuestions
My setup below might be braindamaged, i simply kept going till I had it running, there might be things that i did too complicated.. YMMV.
the info to get it running was scraped from various websites like the abovementioned one:
-------------------------
1) install vde (http://vde.sourceforge.net/)
2) compile kernel with tun/tap and ipv4 masquerading, forwarding, ... i don't remember anymore, i believe masquerading and forwarding was enough.
my network:
--------
host: 192.168.2.189 [assigned via dhcp] gateway host/guest: 192.168.254.254 [guest sees host as this ip] guest: 192.168.254.1
nameserver of isp 1.2.3.4
Host, as root:
------------------------------------------------vde_switch -tap tap0 -daemon
ifconfig tap0 192.168.254.254 [netmask 255.255.255.0] chmod 777 /tmp/vde.ctl # 755 is supposed to work as well echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
Host, as user (example):
------------------------
vdeq qemu-system-x86_64 -boot d -cdrom knoppix.iso
Guest, as root (this is for linux/bsd):
---------------------------------------
ifconfig eth0 192.168.254.1 [netmask 255.255.255.0] route add default gw 192.168.254.254
echo "nameserver 1.2.3.4" >> /etc/resolv.conf
Obviously you'll have to replace the addresses with the appropriate ones on your network. This setup should then allow the guest to communicate with the host and the guest to also reach the internet.
Hope this helps,
Marco
Quoted 7 lines · Alexander Skwar
Hello.
I'm trying to get qemu 0.7.2 on Gentoo Linux to work with tun/tap network - but fail to do so :/
Thus, network isn't setup properly inside the qemu "guest".
Quoted 9 lines
Rather obviously, I seem to be missing something. But what is it? Also, the documentation isn't that clear, as far as the network part is concerned... Also, I'm sorry to bother you on the devel list, but the "plain users" forum is down :(
Thanks a lot for any help you can provide,
Alexander Skwar
Make sure the guest supports the ne2k-pci driver (either compiled in or loaded as a module). from the output you provided, it appears that your guest kernel lacks the right ethernet driver. Check the output of dmesg to see if ne2k is mentioned.
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
Hi!
Quoted 4 lines · Jim C. Brown
Make sure the guest supports the ne2k-pci driver (either compiled in or loaded as a module). from the output you provided, it appears that your guest kernel lacks the right ethernet driver. Check the output of dmesg to see if ne2k is mentioned.
I used the linux-test guest, that's provided on the qemu website and mentioned in the qemu documentation. I'd expect that this has a ne2k-pci driver. If not, maybe the "maintainer" of that package should be contacted? Who is maintaining that?
Thanks a lot,
Alexander Skwar
Signature · 1 line
Ontogeny recapitulates phylogeny.
Quoted 6 lines · Alexander Skwar
QEMU Linux test distribution (based on Redhat 9)
Type 'exit' to halt the system
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
You are missing the correct network driver for the emulated NIC provided by QEMU.
This is not related to TUN/TAP, but only the configuration of your guest to match the virtual hardware provided by QEMU. Your Linux guest should be configured to use the "ne2k-pci" network driver.
Regards
Henrik
Quoted 9 lines · Henrik Nordstrom
Quoted 6 lines · Alexander Skwar
QEMU Linux test distribution (based on Redhat 9)
Type 'exit' to halt the system
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
Quoted 6 lines
You are missing the correct network driver for the emulated NIC provided by QEMU.
This is not related to TUN/TAP, but only the configuration of your guest to match the virtual hardware provided by QEMU. Your Linux guest should be configured to use the "ne2k-pci" network driver.
Thanks. Do you know who is maintaining the linux-test image that's referenced to in the documentation?
http://fabrice.bellard.free.fr/qemu/download.html
-> QEMU disk images
--> linux-test-0.5.1.tar.gz
QEMU Linux demonstration
http://fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz
Alexander Skwar
Signature · 1 line
Predestination was doomed from the start.