Don't understand german? Read or subscribe to my english-only feed.

grml-vnet – create persistent tun/tap devices with integrated bridge handling

Additionally to grml-router (set up your box as NAT-router), grml-bridge (set up your box as bridge) and grml-ap (set up your box as access point) thanks to Gebi the current grml versions provide a simple script named grml-vnet. grml-vnet is a script to create persistent tun/tap devices with integrated bridge handling.

It’s a nice feature to get a bridge setup for use with for example VirtualBox in just a few seconds. Compared to the network setup described in /usr/share/doc/virtualbox-ose/README.Debian of current VirtualBox versions it’s a more generic way to get that feature.

A comfortable way to use grml-vnet is defining it in /etc/network/interfaces (please adjust ‘mika’ with your username ;-)):

auto vnet
iface vnet inet static
post-up /usr/sbin/grml-vnet -u mika -b vnet tap{0..3}
pre-down /usr/sbin/grml-vnet -u mika -b vnet -d tap{0..3}
bridge_ports none
address 192.168.10.1
netmask 255.255.255.0

Then bring up the device and enable IP forwarding:

# ifup vnet
# echo “1” > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A POSTROUTING -o $OUTGOING_NETWORK_DEVICE -j MASQUERADE

That’s it. Now you can configure your virtual machine to use a tap-device (make sure your user is in the vboxusers group (check /etc/group) to be able to access the corresponding devices):

Screenshot of network configuration dialog in Virtualbox

Statically assign an IP address like 192.168.10.2, using netmask 255.255.255.0 and gateway 192.168.10.1 inside the virtual machine to bring your system to the net. You’re really lazy? Then use a DHCP server to also automate assignment of IP addresses. Just adjust your dhcpd.conf:

subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.50 192.168.10.200;
option routers 192.168.10.1;
option domain-name-servers $IP_OF_A_NAMESERVER, IP_OF_ANOTHER_NAMESERVER;
}

Comments are closed.