Qemu with tun virtual networking issues

linux-networkingopenwrtqemu

I'm trying to setup a virtual networking environment using open-wrt qemu and vde2
The script to boot two qemu instances and conenct them together is the following

IMAGE=/home/northpole/openwrt/trunk/bin/x86/openwrt-x86-generic-combined-jffs2-128k.img

sudo killall -q qemu
sudo killall -q wirefilter
sudo killall -q vde_switch

vde_switch -d --hub --sock num1.ctl -f colourful.rc
vde_switch -d --hub --sock num2.ctl -f colourful.rc
cp ${IMAGE} num1.image
cp ${IMAGE} num2.image

sudo qemu \
    -no-acpi -m 32M \
    -net vde,sock=num1.ctl,port=1 -net nic,macaddr=fe:fe:00:00:01:01 \
    -net nic -net tap,ifname=tapwrt1 \
    num1.image&

sudo qemu \
   -no-acpi -m 32M \
   -net vde,sock=num2.ctl,port=2 -net nic,macaddr=fe:fe:00:00:02:01 \
  -net nic -net tap,ifname=tapwrt2 \
 num2.image&

sudo ifconfig tapwrt1 inet 192.168.2.1 up 
sudo ifconfig tapwrt2 inet 192.168.3.1 up
wirefilter --daemon -v num1.ctl:num2.ctl

qemu num2.image
boots properly

but
this script, when run issues

warning: could not configure /dev/net/tun: no virtual network emulation

i'm not very familiar with all of qemu vde wirefilter and bash scripting so any additional tips/guides would be much appreciated

bellow are attached the diagnostics

bash -v ./test.sh 
IMAGE=/home/northpole/openwrt/trunk/bin/x86/openwrt-x86-generic-combined-jffs2-128k.img

sudo killall -q qemu
sudo killall -q wirefilter
sudo killall -q vde_switch

vde_switch -d --hub --sock num1.ctl -f colourful.rc
vde_switch -d --hub --sock num2.ctl -f colourful.rc
cp ${IMAGE} num1.image
cp ${IMAGE} num2.image

sudo qemu \
-no-acpi -m 32M \
-net vde,sock=num1.ctl,port=1 -net nic,macaddr=fe:fe:00:00:01:01 \
-net nic -net tap,ifname=tapwrt1 \
num1.image&

sudo qemu \
   -no-acpi -m 32M \
   -net vde,sock=num2.ctl,port=1 -net nic,macaddr=fe:fe:00:00:02:01 \
  -net nic -net tap,ifname=tapwrt2 \
 num2.image&

sudo ifconfig tapwrt1 inet 192.168.2.1 up 
sudo ifconfig tapwrt2 inet 192.168.3.1 up
warning: could not configure /dev/net/tun: no virtual network emulation
warning: could not configure /dev/net/tun: no virtual network emulation
wirefilter --daemon -v num1.ctl:num2.ctl

the bash -x outputs the same

Best Answer

I fixed it:

tun module was missing for some reason and i didnt need qemu's network config script (/etc/qemu-ifup) so modprobe'd tun removed the script and ran as root and it worked

Related Topic