0

I've got a tun interface set up with an IP address of 172.100.0.1. ip addr confirms this. I've also run

ip route add 192.168.0.0/16 dev tun0

ip route list shows

10.2.164.0/22 dev wlan0 proto kernel scope link src 10.2.166.25
192.168.0.0/16 dev tun0 scope link

The first rule was set up by my network admin. 10.2.166.25 is my IP address on wlan0.

However, when I run ip route get 192.168.1.1, I get

192.168.1.1 via 10.2.164.1 dev wlan0 table 1029 src 10.2.166.25 uid 2000
    cache

I'm at a loss for why it's routing through wlan0. Why isn't my routing rule respected?

ip route show table 0 shows

default via 10.2.164.1 dev wlan0 table 1029 proto static
10.2.164.2/22 dev wlan0 table 1029 proto static scope link
default dev dummy0 table 1003 proto static scope link
10.2.164.0/22 dev wlan0 proto kernel scope link src 10.2.166.25
192.168.0.0/16 dev tun0 scope link
broadcast 10.2.164.0 dev wlan0 table local proto kernel scope link src 10.2.166.25
local 10.2.166.25 dev wlan0 table local proto kernel scope host src 10.2.166.25
broadcast 10.2.167.255 dev wlan0 table local proto kernel scope link src 10.2.166.25
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 10.2.166.25
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
local 172.100.0.1 dev tun0 table local proto kernel scope host src 172.100.0.1
fe80::/64 dev wlan0 table 1029 proto kernel metric 256 pref medium
fe80::/64 dev wlan0 table 1029 proto static metric 10244 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
fe80::/64 dev tun0 table 1034 proto kernel metric 256 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
fe80://64 dev dummy0 table 1003 proto kernel metric 256 pref medium
default dev dummy0 table 1003 proto static metric 1024 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
fe80::/64 dev rmnet_data0 table 1009 proto kernel metric 256 pref medium
default via fe80::953:77d9:c45f:cc0c dev rmnet_data0 table 1009 proto ra metric 1024 expires 64686sec hoplimit 255 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
local ::1 dev lo table local proto unspec metric 0 pref medium
local fe80::3e28:6dff:fee2:f0d0 dev lo table local proto unspec metric 0 pref medium
local fe80::478d:89c5:a152:57aa dev lo table local proto unspec metric 0 pref medium
local fe80::4c49:b3ff:feb7:ac5c dev lo table local proto unspec metric 0 pref medium
local fe80::bc9a:eb93:5ec9:d8e7 dev lo table local proto unspec metric 0 pref medium
ff00::/8 dev dummy0 table local metric 256 pref medium
ff00::/8 dev rmnet_data0 table local metric 256 pref medium
ff00::/8 dev wlan0 table local metric 256 pref medium
ff00::/8 dev tun0 table local metric 256 pref medium
unreachable default dev lo proto kernel metric 4294967295 error -1 pref medium
  • The "table 1029" says your system also uses table-based routing. Inspect all the "normal" routing rules and all rules in all tables in your system, and that should answer your question. If you cannot figure it out, update your question with all the rules, because we cannot guess them. – dirkt Feb 01 '23 at 06:49
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 01 '23 at 07:18
  • @dirkt I've updated with more information. – August Vrubel Feb 01 '23 at 20:24

1 Answers1

0

Table 1029 has the following IPv4 routes

default via 10.2.164.1 dev wlan0 table 1029 proto static
10.2.164.2/22 dev wlan0 table 1029 proto static scope link

Now 192.168.1.1 doesn't match the second route, so the first route applies (and that matches what ip get shows you).

If you check with ip rules, you'll probably see that table 1029 is one of the first checked, way before your new route in the default table has a chance to get considered.

So that's why.

The more interesting question is how you ended up with that many routes in that many tables without knowing about it, and what will break if you mess with it without understanding who did that and why. If the answer is "my sysadmin did that", then you should go talk to your sysadmin. I cannot guess what they were thinking.

dirkt
  • 32,309