mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
42 lines
988 B
Plaintext
42 lines
988 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, linux]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# ip rule
|
|
|
|
> IP routing policy database management.
|
|
> More information: <https://manned.org/ip-rule>.
|
|
|
|
- Display the routing policy:
|
|
|
|
`ip {{[ru|rule]}}`
|
|
|
|
- Create a new generic routing rule with a higher priority than `main`:
|
|
|
|
`sudo ip {{[ru|rule]}} {{[a|add]}} from all lookup {{100}}`
|
|
|
|
- Add a new rule based on packet source addresses:
|
|
|
|
`sudo ip {{[ru|rule]}} {{[a|add]}} from {{192.168.178.2/32}}`
|
|
|
|
- Add a new rule based on packet destination addresses:
|
|
|
|
`sudo ip {{[ru|rule]}} {{[a|add]}} to {{192.168.178.2/32}}`
|
|
|
|
- Delete a rule based on packet source addresses:
|
|
|
|
`sudo ip {{[ru|rule]}} {{[d|delete]}} from {{192.168.178.2/32}}`
|
|
|
|
- Remove all routing rules:
|
|
|
|
`sudo ip {{[ru|rule]}} {{[f|flush]}}`
|
|
|
|
- Save all rules to a file:
|
|
|
|
`ip {{[ru|rule]}} {{[s|save]}} > {{path/to/ip_rules.dat}}`
|
|
|
|
- Restore all rules from a file:
|
|
|
|
`sudo ip < {{path/to/ip_rules.dat}} {{[ru|rule]}} {{[r|restore]}}`
|