1

I know this question was asked here and there but no answer works for me. After hours of googling I can't figure it out. I have Ubuntu 14 server and I need to make few virtual servers - I want something like VPS in DigitalOcean - Virtual machines with external IP.

So I have an Ubuntu server with couple IPs but only one physical network card.

The host system must be accessible only by the main address 198.201.29.211.

Of course virtual machines should behave like normal physical servers and be also able to connect to host server.

This is my /etc/networking/interfaces file:

# Loopback device: auto lo iface lo inet loopback iface lo inet6 loopback # device: eth0 auto eth0 iface eth0 inet static address 198.201.29.211 netmask 255.255.255.192 gateway 198.201.29.193 # default route to access subnet up route add -net 198.201.29.192 netmask 255.255.255.192 gw 198.201.29.193 eth0 auto eth0:0 iface eth0:0 inet static address 198.201.29.247 netmask 255.255.255.192 auto eth0:1 iface eth0:0 inet static address 198.201.29.248 netmask 255.255.255.192 auto eth0:2 iface eth0:0 inet static address 198.201.29.249 netmask 255.255.255.192 

Every IP (except the main one: 198.201.29.211 on eth0) should be exclusively attached to appropriate virtual machine (inside on eth0).

3
  • The IP addresses must be configured in the guests, not in the host! Commented Apr 1, 2016 at 19:20
  • OK - I understand I should remove all eth0:0, eth0:1 etc, yes? Commented Apr 1, 2016 at 19:21
  • But what about br0 or routing? I was trying br0 but without success. How br0 should look like? Commented Apr 1, 2016 at 19:23

1 Answer 1

1

It turned out that the correct configuration is pretty simple. (There is so many confusing answers over the internet). The Network source setting (I use virt-manager) should be set to Host device eth0 (Bridge 'br0').

The address for the virtual machine needs to be set up ONLY in virtual machine what uses it and NOT on the host.

The virtual machine /etc/networking/interfaces looks like this:

auto eth0 iface eth0 inet static address 198.201.29.248 netmask 255.255.255.192 gateway 198.201.29.211 

And this is my working /etc/networking/interfaces (on host machine):

# Loopback device: auto lo iface lo inet loopback iface lo inet6 loopback # device: eth0 auto eth0 iface eth0 inet static address 198.201.29.211 netmask 255.255.255.192 gateway 198.201.29.193 # default route to access subnet up route add -net 198.201.29.192 netmask 255.255.255.192 gw 198.201.29.193 eth0 auto br0 iface br0 inet static address 198.201.29.211 netmask 255.255.255.192 gateway 198.201.29.193 bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0 

Thaks to this post: KVM/Libvirt bridged/routed networking not working on newer guest kernels I have found out that because my server is in Hertzner i also have to switch off ICMP redirections:

for file in `find /proc/ -iname send_redirects`; do echo 0 > $file; done 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.