Gentoo/VM Tap Networking
VM Tap Networking
Most of recent VMs support Linux native tap driver. A simple integration with OpenRC eases the use.
What you get is the following setup:
Host(vbr0) <--+--> (vm0)VM0 | | NAT +--> (vm1)VM1 | (eth0)
The NAT is optional, if you like you can add eth0 to the bridge and have the VMs accessing the network directly.
|Linux Kernel Configuration:|
[*] Networking support ---> Networking options ---> <M> 802.1d Ethernet Bridging [*] IGMP/MLD snooping Device Drivers ---> [*] Network device support ---> <M> Universal TUN/TAP device driver support
|Linux Kernel Configuration: KVM|
Device Drivers ---> [*] Network device support ---> <M> MAC-VLAN support (EXPERIMENTAL) <M> MAC-VLAN based tap driver (EXPERIMENTAL) [*] Virtualization ---> <M> Host kernel accelerator for virtio net (EXPERIMENTAL)
To enable NAT to world, see Gentoo/Firewall_Using_Firehol:
Also recommended to install dnsmasq and use host machine as DNS source pf VMs, so VM can always find correct DNS.
If you are using VPN or dynamic interfacing, modify:
-net nic,netdev=eth0 -netdev tap,id=eth0,ifname=vm0,script=/bin/true
-net nic,netdev=eth0,model=virtio -netdev tap,id=eth0,ifname=vm0,script=/bin/true,vhost=on
Originally written by: Alon Bar-Lev - 2011-11-17
Authors are people who have worked on this document and have made significant changes to its content. If you have edited this article and wish to add yourself to the authors list please read "Who are Authors".