ip-route
TLDR
Show routing table
$ ip route
Add default gateway$ sudo ip route add default via gateway_ip
Add default via interface$ sudo ip route add default dev eth0
Add static route$ sudo ip route add destination_ip via gateway_ip dev eth0
Delete route$ sudo ip route delete destination_ip dev eth0
Change route$ sudo ip route change destination_ip via gateway_ip dev eth0
Get route to destination$ ip route get destination_ip
Show specific table$ ip route list table 100
SYNOPSIS
ip route [command] [OPTIONS]
DESCRIPTION
ip route manages the kernel routing table. It can add, delete, and modify routes, as well as query which route the kernel will use for a specific destination.
PARAMETERS
list (or no command)
Display the routing tableadd
Add a new routedelete
Remove a routechange
Modify an existing routereplace
Change or add if not existsget address
Show route for a specific destinationdefault
Default gateway routevia gateway
Specify next-hop gatewaydev interface
Specify output interfacetable id
Work with a specific routing table
CAVEATS
Routes added are not persistent; use network configuration files for persistence. Multiple routing tables can be used with policy routing. The default table is "main".
HISTORY
ip route is part of iproute2, replacing the deprecated route command.
SEE ALSO
ip(8), ip-address(8), routel(8)


