Add virtual bridge without the loss of networking

bridgekvmnetworkingvirtual machine

There is a dedicated server without KVM-over-IP support.
The server 'owns' two IP addresses, and one of those is used for eth0 at the moment.

The user needs to add a virtual bridge, in order to use the second IP in a KVM guest.
All seems to be easy and straightforward – except most tutorials tell me that I should 'delete' the default ethernet connection. Which is just not that simple.

The main question is in the subject, and the question covers a generic use case.
User wants a virtual machine entirely exposed – without NAT – and with a new IP.

Best Answer

With KVM (but not Xen) you can now use Macvtap instead of bridging. So you don't actually have to tear down the host's network stack and bring it back up with a bridge.

Macvtap works by piggybacking on an existing ethernet interface. It will make your ethernet interface listen on an additional MAC address and it will "steal" the incoming packets addresses to that MAC address so they don't appear to enter through that ethernet interface anymore and instead go to the guest.

If you still want to use a bridging config, you can do it, and of course you realize, it's risky. One way would be to put all of the commands you need to execute to convert the configuration (brtcl, ip, etc...) into a shell script. Schedule an at job to reboot the machine 10 minutes later, then execute the shell script. If it succeeds, cancel the at job, and edit config files to make your changes permanent. If you make a mistake, at least you will get your server back 10 minutes later. I don't recommend it!

Related Question