1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/linux/ip-route.md

37 lines
934 B
Markdown
Raw Normal View History

2021-04-10 21:17:47 +02:00
# ip route
> IP Routing table management subcommand.
> More information: <https://manned.org/ip-route>.
- Display the `main` routing table:
2021-04-10 21:17:47 +02:00
2025-03-09 14:01:49 +02:00
`ip {{[r|route]}}`
2021-04-10 21:17:47 +02:00
- Add a default route using gateway forwarding:
2025-03-09 14:01:49 +02:00
`sudo ip {{[r|route]}} {{[a|add]}} default via {{gateway_ip}}`
2021-04-10 21:17:47 +02:00
- Add a default route using `eth0`:
2025-03-09 14:01:49 +02:00
`sudo ip {{[r|route]}} {{[a|add]}} default dev {{eth0}}`
2021-04-10 21:17:47 +02:00
- Add a static route:
2025-03-09 14:01:49 +02:00
`sudo ip {{[r|route]}} {{[a|add]}} {{destination_ip}} via {{gateway_ip}} dev {{eth0}}`
2021-04-10 21:17:47 +02:00
- Delete a static route:
2025-03-09 14:01:49 +02:00
`sudo ip {{[r|route]}} {{[d|delete]}} {{destination_ip}} dev {{eth0}}`
2021-04-10 21:17:47 +02:00
- Change or replace a static route:
`sudo ip {{[r|route]}} {{change|replace}} {{destination_ip}} via {{gateway_ip}} dev {{eth0}}`
2021-04-10 21:17:47 +02:00
- Show which route will be used by the kernel to reach an IP address:
2025-03-09 14:01:49 +02:00
`ip {{[r|route]}} {{[g|get]}} {{destination_ip}}`
- Display a specific routing table:
`ip {{[r|route]}} {{[l|list]}} {{[t|table]}} {{table_number}}`