2021-09-16 00:02:53 +01:00
|
|
|
# ip rule
|
|
|
|
|
|
|
|
> IP routing policy database management.
|
2024-06-18 04:45:25 +01:00
|
|
|
> More information: <https://manned.org/ip-rule>.
|
2021-09-16 00:02:53 +01:00
|
|
|
|
|
|
|
- Display the routing policy:
|
|
|
|
|
|
|
|
`ip rule {{show|list}}`
|
|
|
|
|
|
|
|
- Add a new rule based on packet source addresses:
|
|
|
|
|
|
|
|
`sudo ip rule add from {{192.168.178.2/32}}`
|
|
|
|
|
|
|
|
- Add a new rule based on packet destination addresses:
|
|
|
|
|
|
|
|
`sudo ip rule add to {{192.168.178.2/32}}`
|
|
|
|
|
|
|
|
- Delete a rule based on packet source addresses:
|
|
|
|
|
|
|
|
`sudo ip rule delete from {{192.168.178.2/32}}`
|
|
|
|
|
|
|
|
- Delete a rule based on packet destination addresses:
|
|
|
|
|
|
|
|
`sudo ip rule delete to {{192.168.178.2/32}}`
|
|
|
|
|
|
|
|
- Flush all deleted rules:
|
|
|
|
|
|
|
|
`ip rule flush`
|
|
|
|
|
|
|
|
- Save all rules to a file:
|
|
|
|
|
|
|
|
`ip rule save > {{path/to/ip_rules.dat}}`
|
|
|
|
|
|
|
|
- Restore all rules from a file:
|
|
|
|
|
|
|
|
`ip rule restore < {{path/to/ip_rules.dat}}`
|