I am trying to understand what is the local routing table.
If I add a random address in it with the following command:
sudo ip route add to local <any-ip-address> dev <network interface>
Now I can ping this address, but no interface listed by ifconfig uses this address.
Example:
$ ping 192.168.22.22 -w 1
PING 192.168.22.22 (192.168.22.22) 56(84) bytes of data.
--- 192.168.22.22 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
$ sudo ip route add to local 192.168.22.22 dev wlp2s0
$ ping 192.168.22.22 -w 1
PING 192.168.22.22 (192.168.22.22) 56(84) bytes of data.
64 bytes from 192.168.22.22: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 192.168.22.22: icmp_seq=2 ttl=64 time=0.015 ms
--- 192.168.22.22 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.015/0.016/0.018/0.004 ms
It feels that it works as a loopback, but from ifconfig, the lo interface still has only the 127.0.0.1 address. If I check this table ip route ls table local
I see the following:
$ ip route ls table local
broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
broadcast 192.168.0.0 dev wlp2s0 proto kernel scope link src 192.168.0.13
local 192.168.0.13 dev wlp2s0 proto kernel scope host src 192.168.0.13
broadcast 192.168.0.255 dev wlp2s0 proto kernel scope link src 192.168.0.13
local 192.168.22.22 dev wlp2s0 scope host
broadcast 192.168.122.0 dev virbr0 proto kernel scope link src 192.168.122.1
local 192.168.122.1 dev virbr0 proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 proto kernel scope link src 192.168.122.1
So what is the local table and in witch scenario should I use it?
I read somewhere that it is for broadcast and addresses hosted by the local machine but I don't understand why do we need a special table for it and when should I add any entry to this table.
Thanks