a distributed VM management tool

Connecting to the Internet


It is sometimes useful to connect the experiment network to the Internet to install software or access external resources. This article describes the simple case of connecting a single VM to the Internet. With minor changes, this technique can also be used to connect an entire experiment to the Internet if the single VM acts as a router.

Single VM

The VM must be configured with at least one network interface:

vm config net LAN

To connect this interface to the Internet, we setup a NAT on the host machine by creating a tap:

tap create LAN ip nat0

Enabling IP forwarding on the host machine:

bash$ sysctl -w net.ipv4.ip_forward=1

And configuring iptables to enable the NAT on the host machine:

bash$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
bash$ iptables -A INPUT -i nat0 -j ACCEPT
bash$ iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
bash$ iptables -A OUTPUT -j ACCEPT

You may need to change eth0 to match the interface on the host machine with Internet access.

On the VM, we would then configure a static IP of, using as the default gateway. On Linux this can be achieved with the following:

ip addr add dev eth0
ip route add default via

You may also need to configure DNS on the VM.


The minimega authors

3 July 2018