(Incus 6.23 here).
Let me explain my issue by means of example. I have a container, named “cndo”, sitting on managed bridge incusbr0. The host has address 10.11.12.1/24 on incusbr0, and the container’s eth0 has picked up address 10.11.12.58.
Now I want to static-route a subnet of IPs to that container (because the container itself acts as a router and has an additional subnet inside it). So I add an ipv4.routes attribute to its NIC:
incus config device override cndo eth0 ipv4.routes=192.168.100.0/24
What I find is: a route has been created on the host, but with no next-hop:
nsrc@brian-kit:~$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
...
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 incusbr0
Therefore, traffic sent to 192.168.100.x isn’t forwarded to the container. Instead, the host sends ARP broadcasts on incusbr0 as if the subnet were directly connected.
To demonstrate: on the host I ping 192.168.100.123, and in another window I run tcpdump, then I see:
nsrc@brian-kit:~$ sudo tcpdump -i incusbr0 -nn arp
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on incusbr0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
20:25:13.901589 ARP, Request who-has 192.168.100.123 tell 10.11.12.1, length 28
20:25:14.920588 ARP, Request who-has 192.168.100.123 tell 10.11.12.1, length 28
20:25:15.944550 ARP, Request who-has 192.168.100.123 tell 10.11.12.1, length 28
What I was expecting to see was that the routes added by incus on the host would have 10.11.12.58 as the next-hop (i.e. the container’s IP address).
# Expected:
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.100.0 10.11.12.58 255.255.255.0 U 0 0 0 incusbr0
The documentation says of the bridged NIC ipv4.routes option:
Comma-delimited list of IPv4 static routes to add on host to NIC [my emphasis]
In order to send traffic for this subnet “to [this particular] NIC” the route needs a next-hop of the NIC’s IP address.
Depending on how this is intended to work, I’d like to raise either a feature request (for routing a subnet to a container) or a bug report.
The thing is, I can’t think of any way in which the current behaviour could ever be used. It’s not even useful as a way to send traffic to a container on incusbr0 which has configured a 192.168.100.x address on its eth0 interface, because the container has no way to respond: the host itself has no IP on 192.168.100. (Note that the ARP broadcasts shown by tcpdump above have a source IP which is not within the 192.168.100 subnet!)
So to me, it seems like a bug. But I thought I’d raise it here for discussion first.
Thanks,
Brian.
P.S. There is a separate ipv4.routes option that you can apply to the bridge itself, as opposed to the container NIC. As far as I can see, this has the same problem: with no next-hop, and no IP address on the host which belongs to the subnet, there doesn’t seem any possible way in which it can be useful as it is right now.
In this case, there is no implicit next-hop - whereas there is when a route is attached to a container NIC. Hence I’d expect the next-hop to be specified as part of the setting, but it doesn’t seem possible:
nsrc@brian-kit:~$ incus network set incusbr0 ipv4.routes '192.168.101/24 10.11.12.58'
Error: Invalid value for network "incusbr0" option "ipv4.routes": Item "192.168.101/24 10.11.12.58": invalid CIDR address: 192.168.101/24 10.11.12.58
nsrc@brian-kit:~$ incus network set incusbr0 ipv4.routes '192.168.101/24 via 10.11.12.58'
Error: Invalid value for network "incusbr0" option "ipv4.routes": Item "192.168.101/24 via 10.11.12.58": invalid CIDR address: 192.168.101/24 via 10.11.12.58