Routing policy rules decide whether packets follow the normal routing table or are redirected to another lookup path before a route is chosen. Listing those rules is the quickest way to confirm why a host with multiple uplinks, source-based routing, or marked traffic is not following the expected route.
The ip rule show command reads the routing policy database managed by iproute2. Rules are evaluated by priority, where lower numbers are processed first, and a default Linux system normally shows the built-in local, main, and default lookups.
An unexpected rule above main can override an otherwise correct route table, so rule inspection usually needs to be paired with route-table inspection. If a custom rule points to a numbered or named table, check that table before changing live networking.
Steps to show routing policy rules with ip rule:
- Show the current policy-routing rules.
$ ip rule show 0: from all lookup local 32766: from all lookup main 32767: from all lookup default
- Read the list from the lowest numeric priority to the highest.
Lower numbers are evaluated first, so priority 0 runs before 32766 and 32767.
- Separate the built-in rules from any custom policy rules.
A default host usually shows only local, main, and default. Extra selectors such as from 192.0.2.10, fwmark, or iif usually indicate custom policy routing.
- Show detailed rule attributes when the plain list is not enough.
$ ip -details rule show 0: from all lookup local proto kernel 32766: from all lookup main proto kernel 32767: from all lookup default proto kernel
The detailed form can expose metadata such as proto kernel and helps confirm how a rule was inserted.
- Inspect the referenced route table directly whenever a custom rule points traffic away from main.
- Run ip rule show again after adding or deleting rules to confirm the final priority order matches the intended policy.
A correct selector with the wrong priority can still lose to a broader rule that is evaluated earlier.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
