Hi. For my project i need different lookup table than it is on my host:
# ip rule
0: from all lookup local
1000: from all lookup [l3mdev-table]
32766: from all lookup main
32767: from all lookup default
needed chain:
1000: from all lookup [l3mdev-table]
2000: from all lookup local
32766: from all lookup main
32767: from all lookup default
I see that VyOS has this rules sequence:
1000: from all lookup [l3mdev-table]
2000: from all lookup [l3mdev-table] unreachable
32765: from all lookup local
32766: from all lookup main
32767: from all lookup default
and it persists across reboots and interfaces flaps. Is that possible to do the same on plain recent Debian or Ubuntu?
I created systemd service like this:
[Unit]
Description=Put l3mdev-table lookup first in ip rules
Requires=network-online.target
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/sbin/ipruleinsert.sh
[Install]
WantedBy=multi-user.target
where the script does the following:
#!/usr/bin/bash
ip -4 rule | egrep '^0:' &> /dev/null
if [ $? == 0 ]; then
ip -4 rule del 0
fi
ip -r rule | grep "2000:" &> /dev/null
if [ $? != 0 ]; then
ip -4 rule add pref 2000 table local
fi
it works across reboots, but the line with preference 2000 disappears unfortunately after network interfaces flaps, or “systemctl restart systemd-networkd” or after netplan apply.
That is probably not VyOS related directly, but the place seem to be the only one where it could be resolved)