Changing default ip rule priority for main table
Solution 1
The pref
keyword allows to override the priority.
ip rule add pref 32000 from all lookup main
ip rule del pref 32766 from all lookup main
ip rule add pref 32010 from all lookup upstream01
ip rule add pref 32020 from all lookup upstream02
Solution 2
You can delete the existing "default" rule and replace it with rules that suit your situation:
# delete the existing default rule
ip rule del from all lookup default priority 32767
# add your custom rules
ip rule add from all lookup upstream01 priority 32767
ip rule add from all lookup upstream02 priority 32768
# replace the "default" rule
ip rule add from all lookup default priority 32769
The result should look like this:
0: from all lookup local
32766: from all lookup main
32767: from all lookup upstream01
32768: from all lookup upstream02
32769: from all lookup default
Related videos on Youtube
Dmitriy Sosunov
Updated on September 18, 2022Comments
-
Dmitriy Sosunov over 1 year
Please, suggest how to add ip rule right after main rule.
I have the following configuration and it needed to be restored on boot.
32766: from all lookup main 32766: from all lookup upstream01 32766: from all lookup upstream02 32767: from all lookup default
The challenge is to add rules for tables upstream 01 & 02 in correct order right after main. The priority for main & default don't have any gap to inject rules between them. I can only use the same priority of rule to main table to add it as I show above.
So, I see multiple options:
a. change default priority rule for main table to make a gap between rules to have ability define a priority in required order. But I don't know how to do this.
b. Found a way how to inject rules between "main" and "upstream01".