On 2/25/24 10:34, Jeffrey Walton wrote:
Hi Everyone,
I'm having trouble understanding what I need to do so my VM guests use
the DHCP server on my LAN. I've read
<
https://wiki.libvirt.org/VirtualNetworking.html#virtual-networking>,
but I don't see the use case covered. There is a section on dns-dhcp,
but it looks like some sort of libvirt-internal setup so guests get
their networking params from libvirt, and not my DHCP server.
(I am looking for something similar to VirtualBox and Bridged
networking. VBox does what I want when I select a bridged adapter).
How do I set up networking so the VM Guest uses LAN DHCP?
You have basically two options:
1) create a linux bridge (brctl addbr ...) or an OpenVSwitch bridge,
plug your eth0 into it and then configure VMs to have their vNICs
plugged into the bridge (<interface type='bridge'> <source
bridge='...'/> ..).
2) Use macvtap (<interface type='direct'> <source dev='eth0'/>
...).
There is a caveat though. While 2) is less labor intensive, it won't
allow VMs to talk to each other. For that you'd need a switch with so
called hairpin turned on.
Michal