network route not working for subnetwork even if it should have to work #321

Closed
opened 2025-11-20 05:09:33 -05:00 by saavagebueno · 8 comments
Owner

Originally created by @lfarkas on GitHub (May 8, 2023).

The network routes is a very nice feature in netbird, but one of my current topology it's not working.
I've 2 network, let it be office and home:

  • office 192.168.0.0/16
  • home 192.168.253/24

I've one client (actually more but let's make it more simple) in each network and i'd like route through these client from each network to the other. This normally works (eg with openvpn) and it's works even with netbird,
BUT do not work if i set both routes in https://app.netbird.io/routes and try to advertise them through netbird.

The reason is simple from the log:

2023-05-08T12:50:55+02:00 INFO client/internal/peer/conn.go:348: connected to peer gsrpCbJwc8lkmNV783rxIHpyj+zZIhy/rFj5HsfVuBY= [laddr <-> raddr] [192.168.209.150:51820 <-> 192.168.209.1:38584]
2023-05-08T12:50:55+02:00 INFO client/internal/routemanager/client.go:111: new chosen route is chccqaat2r9s73b1k4q0 with peer gsrpCbJwc8lkmNV783rxIHpyj+zZIhy/rFj5HsfVuBY= with score 11
2023-05-08T12:50:55+02:00 WARN client/internal/routemanager/systemops_nonandroid.go:27: skipping adding a new route for network 192.168.253.0/24 because it already exists and is pointing to the non default gateway: 192.168.209.150

it seems that netbird see something similar route in the local routing table and skip this, which is a bug. in linux (any any other os) the routing decision is working in a way that always try to choose the smallest network which contains the given destination. so in this case there can be 2 orverlapping route in the routing table the os always choose the smallest one eg. with this routing table:

192.168.0.0     0.0.0.0         255.255.0.0     U     100    0        0 enp2s0
192.168.253.0     100.76.24.179   255.255.255.0     UG    0      0        0 wt0

the host 192.168.253.2 should have to route through wt0.

The strange thing is that the opposite works in the other side of the network. ie. routeing from home to office has this routing table:

0.0.0.0         192.168.253.1   0.0.0.0         UG    100    0        0 enp6s0
100.76.0.0      0.0.0.0         255.255.0.0     U     0      0        0 wt0
192.168.0.0     100.76.24.179   255.255.0.0     UG    0      0        0 wt0
192.168.253.0   0.0.0.0         255.255.255.0   U     100    0        0 enp6s0

and in the log:

2023-05-08T12:50:55+02:00 INFO client/internal/peer/conn.go:348: connected to peer hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0= [laddr <-> raddr] [192.168.253.9:51820 <-> 185.199.30.141:2563]
2023-05-08T12:50:55+02:00 INFO client/internal/routemanager/client.go:111: new chosen route is cgva4m2t2r9s73c4r8tg with peer hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0= with score 11

so when the remote is overlapping BUT larger then the routing rule is added.

Originally created by @lfarkas on GitHub (May 8, 2023). The network routes is a very nice feature in netbird, but one of my current topology it's not working. I've 2 network, let it be office and home: - office 192.168.0.0/16 - home 192.168.253/24 I've one client (actually more but let's make it more simple) in each network and i'd like route through these client from each network to the other. This normally works (eg with openvpn) and it's works even with netbird, BUT do not work if i set both routes in https://app.netbird.io/routes and try to advertise them through netbird. The reason is simple from the log: ``` 2023-05-08T12:50:55+02:00 INFO client/internal/peer/conn.go:348: connected to peer gsrpCbJwc8lkmNV783rxIHpyj+zZIhy/rFj5HsfVuBY= [laddr <-> raddr] [192.168.209.150:51820 <-> 192.168.209.1:38584] 2023-05-08T12:50:55+02:00 INFO client/internal/routemanager/client.go:111: new chosen route is chccqaat2r9s73b1k4q0 with peer gsrpCbJwc8lkmNV783rxIHpyj+zZIhy/rFj5HsfVuBY= with score 11 2023-05-08T12:50:55+02:00 WARN client/internal/routemanager/systemops_nonandroid.go:27: skipping adding a new route for network 192.168.253.0/24 because it already exists and is pointing to the non default gateway: 192.168.209.150 ``` it seems that netbird see something similar route in the local routing table and skip this, which is a bug. in linux (any any other os) the routing decision is working in a way that always try to choose the smallest network which contains the given destination. so in this case there can be 2 orverlapping route in the routing table the os always choose the smallest one eg. with this routing table: ``` 192.168.0.0 0.0.0.0 255.255.0.0 U 100 0 0 enp2s0 192.168.253.0 100.76.24.179 255.255.255.0 UG 0 0 0 wt0 ``` the host 192.168.253.2 should have to route through wt0. The strange thing is that the opposite works in the other side of the network. ie. routeing from home to office has this routing table: ``` 0.0.0.0 192.168.253.1 0.0.0.0 UG 100 0 0 enp6s0 100.76.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wt0 192.168.0.0 100.76.24.179 255.255.0.0 UG 0 0 0 wt0 192.168.253.0 0.0.0.0 255.255.255.0 U 100 0 0 enp6s0 ``` and in the log: ``` 2023-05-08T12:50:55+02:00 INFO client/internal/peer/conn.go:348: connected to peer hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0= [laddr <-> raddr] [192.168.253.9:51820 <-> 185.199.30.141:2563] 2023-05-08T12:50:55+02:00 INFO client/internal/routemanager/client.go:111: new chosen route is cgva4m2t2r9s73c4r8tg with peer hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0= with score 11 ``` so when the remote is overlapping BUT larger then the routing rule is added.
saavagebueno added the waiting-feedback label 2025-11-20 05:09:33 -05:00
Author
Owner

@mlsmaycon commented on GitHub (Jun 19, 2023):

The PR #945 fixes it and it will be available in the next release.

@mlsmaycon commented on GitHub (Jun 19, 2023): The PR #945 fixes it and it will be available in the next release.
Author
Owner

@lfarkas commented on GitHub (Aug 2, 2023):

i already reconfigure all of our networks so i can't test it now. but let's assume working if not i'll write a new issue.

@lfarkas commented on GitHub (Aug 2, 2023): i already reconfigure all of our networks so i can't test it now. but let's assume working if not i'll write a new issue.
Author
Owner

@lfarkas commented on GitHub (Oct 28, 2023):

this is not working again in the latest release netbird-0.24.2-1.x86_64.
i'm just now connected to a wifi network where the local ip address is:

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.185  netmask 255.255.255.0  broadcast 192.168.0.255

ad the same time one of my network which should have to be routed is:
192.168.0.0/16
so the peer's route should have to be added, but in the log i can see this:

2023-10-28T11:17:58+02:00 WARN client/internal/routemanager/client.go:119: the network 192.168.0.0/16 has not been assigned a routing peer as no peers from the list [FfiyZKMquYILabBxOquw/jXEuTjhBq6tUvBEPdV3ckY= hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0=] are currently connected

imho it's the same bug as earlier so it seems still not solved.

@lfarkas commented on GitHub (Oct 28, 2023): this is not working again in the latest release netbird-0.24.2-1.x86_64. i'm just now connected to a wifi network where the local ip address is: ``` wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.185 netmask 255.255.255.0 broadcast 192.168.0.255 ``` ad the same time one of my network which should have to be routed is: `192.168.0.0/16` so the peer's route should have to be added, but in the log i can see this: ``` 2023-10-28T11:17:58+02:00 WARN client/internal/routemanager/client.go:119: the network 192.168.0.0/16 has not been assigned a routing peer as no peers from the list [FfiyZKMquYILabBxOquw/jXEuTjhBq6tUvBEPdV3ckY= hCDjKQBW9TBwsZigTRXxvVzpAYE+ZqDHBol4sOSUMl0=] are currently connected ``` imho it's the same bug as earlier so it seems still not solved.
Author
Owner

@mlsmaycon commented on GitHub (Oct 29, 2023):

Hello @lfarkas can you run the client with debug logs?

You can do that by running the following commands:

sudo netbird service stop
sudo netbird up -F -l debug | tee /tmp/netbird.debug.log

After running for 60s you can share the logs for us to check them.

@mlsmaycon commented on GitHub (Oct 29, 2023): Hello @lfarkas can you run the client with debug logs? You can do that by running the following commands: ```shell sudo netbird service stop sudo netbird up -F -l debug | tee /tmp/netbird.debug.log ``` After running for 60s you can share the logs for us to check them.
Author
Owner

@lfarkas commented on GitHub (Oct 30, 2023):

netbird.log

@lfarkas commented on GitHub (Oct 30, 2023): [netbird.log](https://github.com/netbirdio/netbird/files/13208276/netbird.log)
Author
Owner

@lfarkas commented on GitHub (Nov 2, 2023):

do you need any further info?

@lfarkas commented on GitHub (Nov 2, 2023): do you need any further info?
Author
Owner

@mlsmaycon commented on GitHub (Nov 2, 2023):

Hello, @lfarkas the issue happened because the default gateway of your local network is 192.168.0.1, which is part of the 192.168.0.0/16 network. See the log event below:

2023-10-30T18:46:59+01:00 WARN client/internal/routemanager/systemops_nonandroid.go:24: skipping adding a new route for network 192.168.0.0/16 because it overlaps with the default gateway: 192.168.0.1

This shouldn't happen as the local network is smaller. We will update the logic to prevent this case. Thanks for the logs.

@mlsmaycon commented on GitHub (Nov 2, 2023): Hello, @lfarkas the issue happened because the default gateway of your local network is 192.168.0.1, which is part of the `192.168.0.0/16` network. See the log event below: ``` 2023-10-30T18:46:59+01:00 WARN client/internal/routemanager/systemops_nonandroid.go:24: skipping adding a new route for network 192.168.0.0/16 because it overlaps with the default gateway: 192.168.0.1 ``` This shouldn't happen as the local network is smaller. We will update the logic to prevent this case. Thanks for the logs.
Author
Owner

@lfarkas commented on GitHub (Nov 24, 2023):

work in 24.3

@lfarkas commented on GitHub (Nov 24, 2023): work in 24.3
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#321