Routing to VM's internal subnet

I have a VM which has an internal bridge with a subnet. On the host I need to route traffic for a specific subnet to a specific VM.

This achieved the outcome manually: ip route add 10.40.20.0/24 via 10.40.16.167 (where 10.40.16.167 is a VM running on a managed incus bridge, and that VM has an internal 10.40.20.0/24 subnet)

I can’t add this route in /etc/network/interfaces on the host, because I believe incusbr0 doesn’t exist till incus starts.

Is there a way I can tell incus to add this route once incusbr0 is brought up? Thanks!

Ok, totally mis-read that initially.

There will be many ways to do this on the host, for example with systemd, write a small script to add the route you want, then add something this to [Service] to go with your ExecStart;

ExecStartPre=timeout 60s bash -c 'until ip a s dev incusbr0; do sleep 1; done'

Unfortunately for /etc/init.d fans, systemd does seem to have solutions to many such problems :frowning:

Have you tried setting ipv4.routes on the incusbr0 network?