qemu tap networking quick and dirty

Aug 02, 2013 16:11

root@host # zcat /proc/config.gz | grep TUN
CONFIG_TUN=y
root@host # stat -t /dev/net/tun
/dev/net/tun 0 0 21b6 0 0 5 1066 1 a c8 1375444591 1375444591 1375444900 0 4096
root@host # qemu-system-x86_64 -drive file=systemrescuecd-x86-3.7.1.iso,media=cdrom -net nic -net tap,script=no,downscript=no -boot order=d -enable-kvm -usb -usbdevice tablet
ioctl(8, TUNGETFEATURES, 0x7fffc5c600a4) = 0
ioctl(8, TUNGETFEATURES, 0x7fffc5c600a4) = 0
ioctl(8, TUNSETVNETHDRSZ, 0x7fffc5c600a0) = -1 EBADFD (File descriptor in bad state)
ioctl(8, TUNSETIFF, 0x7fffc5c600b0) = 0
ioctl(8, TUNSETOFFLOAD, 0x11) = 0
ioctl(8, TUNSETOFFLOAD, 0) = 0
ioctl(8, TUNSETOFFLOAD, 0) = 0
ioctl(8, TUNGETVNETHDRSZ, 0x7fffc5c60044) = 0
ioctl(8, TUNSETVNETHDRSZ, 0x7fffc5c60038) = 0
ioctl(8, TUNSETVNETHDRSZ, 0x7fffc5c60044) = 0
ioctl(8, TUNSETVNETHDRSZ, 0x7fffc5c60038) = 0
ioctl(8, TUNSETSNDBUF, 0x7fffc5c600a4) = 0
root@host # ip r a 192.168.1.0/24 dev tap0
root@guest # ip a a dev ens3 192.168.1.1/24
root@guest # ip r a default dev ens3
root@host # ping 192.168.1.1
root@guest # ping host

TODO:
# script and downscript must create and destroy the tap0 interface (so qemu doesn't need root to run)
# -runas isn't working
# bridge taps to create virtual network (-netdev bridge mb?)
# provide access to/from the outside world
# ioctl(8, TUNSETVNETHDRSZ, 0x7fffc5c600a0) = -1 EBADFD (File descriptor in bad state)
# look at -netdev socket

README:
http://backreference.org/2010/03/26/tuntap-interface-tutorial/
https://bugzilla.redhat.com/show_bug.cgi?id=593903#c2
Previous post Next post
Up