ip-rule
TLDR
Display the routing policy database
SYNOPSIS
ip rule [command] [options]
DESCRIPTION
ip rule manages the routing policy database (RPDB), which controls how routing table lookups are performed. Rules define selectors (conditions) and actions (which table to consult) enabling policy-based routing.
Multiple routing tables can exist, each with different routes. Rules determine which table is consulted based on source address, destination, interface, firewall mark, and other criteria. This enables complex routing scenarios like multi-homing.
PARAMETERS
add [selector] [action]
Add a new ruledelete [selector]
Remove a ruleflush
Delete all rulessave
Output rules to stdout (for backup)restore
Restore rules from stdinfrom PREFIX
Match source addressto PREFIX
Match destination addresslookup TABLE
Route table to use (number or name)priority NUM
Rule priority (lower = higher priority)
CAVEATS
Modifying rules requires root privileges. Rule changes are not persistent across reboots without additional configuration. Incorrect rules can break network connectivity.
HISTORY
Policy routing was introduced in Linux 2.2 as part of the advanced routing capabilities. The ip rule command in iproute2 provides management of these features.
SEE ALSO
ip(8), ip-route(8), ip-route-add(8)


