KVM virtual machines obtaining addresses via dhcp IPv4

James asked:

I’ve got a DHCP and DNS server on a different machine to my KVM host. Is there any way I can get VM’s to get an IP address from the DHCP server, with traffic being directed to the VM via the hosts NIC? I could set everything up statically, but then I’d have to keep everything in sync on the DNS server. The host is running Debian Buster and the DHCP/DNS is on a OpenWRT machine. The idea is to try and make the networking for VMs appear like any other machine on the internal network. I’ve seen this working on ESXi (with different DHCP/DNS servers) but don’t know how much work behind the scenes VMWare had to do to make this possible?

My answer:


Sure, you can just set up a bridge with your NIC as the only (physical) interface connected to it. (You transfer the IP address configuration from the physical interface to the bridge, and remove the configuration for the physical interface.) For example:

iface enp1s0 inet manual

auto br0
iface br0 inet static
        address 192.168.42.2/24
        gateway 192.168.42.1
        bridge_ports enp1s0

Then you can set each VM’s virtual NIC to use that bridge. For example:

virt-manager NIC configuration


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.