r/linuxadmin • u/cjbarone • Sep 05 '26
libvirt VMs on isolated network not getting DHCP
In a lab setting, I have a Debian Trixie VM that I'm trying to get setup like a router, and a client Trixie VM whose sole purpose is to get a DHCP lease and get out to the Internet.
On the "router" VM, I have disabled nftables and flushed the rules. Even when I assign an IP address to the client and router VMs and attach them to the same virtual network, they cannot ping each other.
<network>
<name>isolated-network</name>
<uuid>2d9a40eb-c078-4c7e-998e-4ed1bf46786e</uuid>
<bridge name="virbr1" stp="on" delay="0"/>
<mac address="52:54:00:12:8d:b8"/>
<domain name="isolated-network"/>
</network>I am hoping this is something simple, but it's been driving me a little crazy trying to figure it out. How can I get these two isolated VMs to talk to each other?
1
u/deeseearr Sep 05 '26
Are you sure that the isolated network is running? The config looks okay, but if you don't assign an IP address to the host (and I don't know if you even want to) then the host may decide that there's no reason to bother bringing it up.
Check the status using "ip link show virbr1" or something similar on the host server. You can also look at this from a different angle by running "tcpdump" on both guests and the host and seeing if there is any network traffic visible at all. Ideally, they should all be seeing the same things at the same time but if you see nothing at all on one or more of them then you're not really attached to the network.
1
u/Gurufedell Sep 05 '26
You simply have not given your virtual bridge an ip address and did not give it a DHCP range so it's not acting as DHCP server for connected client interfaces.
Your xml file should look like, make sure to add an IP address and DHCP range.
virsh net-edit --network isolated-network1
u/showbizusa25 Sep 06 '26
Your topology makes sense. I wouldn’t put DHCP on the libvirt network either if the goal is to actually build/test the router VM.
Since static IPs can’t even ping yet, I’d ignore DHCP/NAT for now and troubleshoot L2 first. Make sure both the router’s LAN vNIC and client vNIC are actually attached to virbr1, then check
bridge linkon the host andip linkinside both VMs.Once static ping works across virbr1, then bring up DHCP on the router VM’s LAN interface. After that, tackle forwarding/NAT.
If you want, DM me the
virsh domiflistoutput for both VMs and I can help trace where it’s breaking.1
u/rankinrez Sep 09 '26
Have you enabled forwarding for the interfaces with sysctl?
1
u/michaelpaoli Sep 06 '26
The qemu-kvm native guest networks at least by default isolate the VMs, allowing them only to communicate with the host, and possibly through it, if forwarding (and possibly also nat) are enabled.
If you want the VMs to communicate with The Internet, can have gateway IP(s) of host on bridge, rather than some other interface on the host, then one can use globally routable IPs on the VMs, or instead use NAT. One can even do both NAT for IPv4 and globally routable IPs for IPv6.