0

I was setting up a server recently, and I was supposed to assign one of the public IP available for the server to a KVM guest. The server have the following setup:

eno1 - main internet connection of the host, assigned with a public ip lo - loopback virbr0 - bridge to virtual nic created by KVM

using Open Nebula I assigned virbr0 to the virtual network assigned to the guest machine and setup the specific config to the guest machine:

guest machine - /etc/network/interfaces

auto ens3
iface ens3 inet static
    address y.y.y.y
    netmask 255.255.255.255
    pointopoint <provided by host provider>
    gateway <provided by host provider>

finishing the guest configuration, I run the following on the host:

 brctl addif virbr0 eno1

After running this I was able to access the guest machine through the newly assigned IP. However, I can no longer access the host through SSH or Open Nebula.

Why does this happen? Is there also a way to setup virbr0 configuration on /etc/network/interfaces so it would stay persistent even when the host crashes?

1

You need a bridge on the host. Let's say it has address x.x.x.x now.

auto eno1
iface eno1 inet manual
auto br1
iface br1 inet static
   address x.x.x.x
   netmask <hostnetmask>
   gateway <hostgateway>
   bridge_ports eno1
   bridge_stp off
   bridge_maxwait 0
   bridge_fd 0

These are the settings to configure the network at boot.

If you have only have a single nic, reboot your host with these settings to activate the bridge. Or restart networking with screen or tmux.

If you have a dual nic setup, you don't need to reboot, simply SSH into your machine via the address on nic2 (eno2) and then

ifdown eno1
ip link add name br1 type bridge
ip link set dev br1 up
ip link set dev eno1 master br1
ip addr flush eno1
ifup eno1

Finally start your guest with the br1 network interface.

sudo kvm -net nic -net bridge,br=br1 ...
  • If I apply x.x.x.x, which is my main server IP, to bridge network, will I still be able to ssh to the server? – Dominick Navarro Feb 20 at 1:59
  • Yes, you'll both have x.x.x.x for your host and y.y.y.y for your guest on a single interface. That's exactly what a bridge does. If you add your current host config to your question, I'll update the answer with the correct network settings. – Stefaan Ghysels Feb 20 at 7:51
  • Thanks, I will wait for the serial console access before trying, just to be safe. If things don't work, I'll post my host config. – Dominick Navarro Feb 20 at 9:18
0

You need to put the ip address on the bridge device "virbr0:

ip addr add y.y.y.y/32 dev virbr0

Look at the @stefaan-ghysels answer for details to configure at boot time.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.