I'm working with Ubuntu 24.04 Desktop and I created a VM connected to the default libvirt-NAT-Bridge and a second isolated network.
The bridged network is virbr0: 192.168.122.0/24
the host got 192.168.122.1
and the VM got static 192.168.122.128
. The isolated network is 10.95.212.0/24
.
I want to be able to ping/ssh into hosts in the isolated network that's why I set a static route (route add ...
) on the host. It works, but it did not survive a reboot. I tried nmtui
but the route vanishes on reboot.
I thought about virsh net-edit default
, but I didn't found any documentation how to do it.
Where do I have to define the route that it survives the reboot?
One option is to set up the static route on your host. It sounds like you tried to do that, but since you didn't provide us with details it's hard to tell why it didn't work.
With my Ubuntu 24.04 system, I started with an interface configuration created like this:
This gets me an address on the default libvirt network (which on my system is 192.168.124.0/24):
To add a static route to this configuration, I can modify it with the
nmcli modify
command:After a reboot, I have:
According to the libvirt documentation, it should be possible to define static routes in the network definition so that they are provided to your hosts via DHCP. I experimented with this a bit, but it doesn't appear to work as documented.
Fortunately, it is also possible to specify arbitrary dnsmasq options, which means we can add the necessary dnsmasq configuration like this:
With this in place, hosts that use DHCP for interface configuration will receive the route via a DHCP option. I've tested the above configuration and it works for hosts using NetworkManager and for hosts using systemd-networkd.