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?
1 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:
-
One also needs to check
FORWARD
chain rules so that traffic from / to bridge is allowed to be forwarded. Jun 22, 2020 at 6:53 -
Would this then cause problems accessing the host from the network? Thanks to both you for your replies.– JamesJun 22, 2020 at 12:36