[Netkit.users] Multiple TAP interfaces

Massimo Rimondini rimondin at dia.uniroma3.it
Thu Sep 22 16:12:59 CEST 2011

Dear Gareth,

> Dear All,
> I was wondering if there was a simple way to enable multiple tap
> interfaces, i.e. three VMs, each with a single tap?  I have looked at
> the code and noticed that the tap devices are created as nk_tap_

Exactly. Currently there is no way to do it with standard tools.

> I am going to assume the answer to my question is no at the moment since
> I am not sure how the different VMs are going know which tap interface
> belongs to it. 

And, in fact, they don't know, because every VM assumes to be connected to the same nk_tap_

> However, I would welcome some discussion about how this
> could be achieved (through a different naming convention or something
> similar).

I guess an additional (maybe optional) parameter to the interface specification in vstart.
Something like:
vstart pc1 --eth0=tap,,,<guest_if_name>

> If I can tap out with individual machines then I won't need to use the
> UML_SWITCH and I can then replace it with VLANs using OpenVSwitch.  Does
> anybody have any alternative ideas as to how this could be achieved?

At present, only "by hand", I'm afraid. You can start uml_switches connected to tap interfaces beforehand, instructing them to create their sockets inside $HOME/.netkit/hubs/vhub_$USERNAME_hubname.cnct and then instruct vstart to attach the applicable interfaces to hubname instead of an arbitrary named collision domain. Practical example:

> $ CUSTOM_TAP=myTap
> $ sudo $NETKIT_HOME/bin/uml_tools/tunctl -u $USERNAME -t $CUSTOM_TAP
> Set 'myTap' persistent and owned by uid 1000
> $ sudo ifconfig $CUSTOM_TAP up
> $ sudo chmod 666 /dev/net/tun
> $ $NETKIT_HOME/bin/uml_switch -tap $CUSTOM_TAP -hub -unix $HOME/.netkit/hubs/vhub_${USERNAME}_${CUSTOM_TAP}.cnct </dev/null >&/dev/null &
> [1] 19005
> $ vstart pc1 --eth0=$CUSTOM_TAP

Note that neither routing nor natting/masquerading are activated on your host by using these commands: choosing to have them highly depends on your actual needs. Moreover, the guest-side interface must still be assigned an address (and, possibly, the guest also needs a default route).

After use, remember to reset permissions for /dev/net/tun (they should be 660) and to disable routing/natting on your host.


> Thanks for your help,
> Gareth
> _______________________________________________
> Netkit.users mailing list
> Netkit.users a list.dia.uniroma3.it
> http://list.dia.uniroma3.it/mailman/listinfo/netkit.users

More information about the Netkit.users mailing list