I’ve recently rented a new server from Hetzner and decided to run virtual machines on it.
Here’s how to set up networking so the vms can connect to the Internet (and the other vms or host) while being reachable from the Internet themselves.
The assumptions are:
- Host with one public ip (IP_HOST here)
- Two additional public ips (IP2** + **IP3)
- Ubuntu 12.04 LTS on all systems
- Virtualization with KVM
On the host:
Install kvm, create your VMs (you can connect to them using the visual admin tool (
ssh -X) and configure your host:
On Virtual Machine 1:
On Virtual Machine 2
And that’s basically it. However, in KVM config (host) you should match the MAC-addresses of your interfaces like this:
On the host run
ifconfig to obtain the MACs, you should see something like this:
Copy the HWaddr-values to the config files for the respective VMs, for example in my case for VM1 to
And do the same with Virtual Machine 2.
Restart networking (and virtual machines if needed) and everything should work. And you can reach your virtual machines from the outside (f.ex. with ssh) and they can connect out, as well.