Table "local" has a default route. Why doesn't it suppress the other 2 tables?

Hi. I need to clarify something. After reading ip-rule(8) I thought that if a table has a matching route the next tables wouldn't be checked.

I didn't create any custom rules. Here's what we have on OpenWRT:

# ip rule
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
# ip route show local
default via 10.82.206.5 dev eth0.2  src 10.82.206.24
# ip route show main
default via 10.82.206.5 dev eth0.2  src 10.82.206.24
# ip route show default
default via 10.82.206.5 dev eth0.2  src 10.82.206.24
10.82.206.0/23 dev eth0.2 scope link  src 10.82.206.24
192.168.43.0/24 dev br-lan scope link  src 192.168.43.1

So the table "local" has higher priority and it has a default route. Then how come the routes in the other tables ever effective?

I have no explanation how exactly you got these results, because the correct command syntax is ip route show table {table name}.

The local table should only handle internal device traffic (between internal ports) and also includes the loopback adapter and broadcast traffic. It is maintained by the kernel and cannot be modified.

The default table (despite its name) has some special purpose and should be empty by default.

Maybe you have some aliases in place?

root@barracuda:[~]#ip route show local
Error: any valid prefix is expected rather than "local".
root@barracuda:[~]#ip route show main
Error: any valid prefix is expected rather than "main".

Thank you. I was fooled by the output that looked sane.
On OpenWRT /sbin/ip does not fail on some invalid commands. Maybe it's a BusyBox thing.

My output is also from OpenWrt. What is the output of:

opkg list-installed | grep ip-
which ip
/sbin/ip -V
root@OpenWrt:~# opkg list-installed | grep ip-
root@OpenWrt:~# which ip
/sbin/ip
root@OpenWrt:~# /sbin/ip -V
BusyBox v1.35.0 (2022-07-31 15:12:47 UTC) multi-call binary.

Usage: ip [OPTIONS] address|route|link|neigh|rule [ARGS]

OPTIONS := -f[amily] inet|inet6|link | -o[neline]

ip addr add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]
ip route list|flush|add|del|change|append|replace|test ROUTE
ip link set IFACE [up|down] [arp on|off] [multicast on|off]
        [promisc on|off] [mtu NUM] [name NAME] [qlen NUM] [address MAC]
        [master IFACE | nomaster] [netns PID]
ip neigh show|flush [to PREFIX] [dev DEV] [nud STATE]
ip rule [list] | add|del SELECTOR ACTION

There isn't even a show in ip route there, so don't trust it too much.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.