links
ip route provides management tools for manipulating any of the routing tables. Operations include displaying routes or
the routing cache, adding routes, deleting routes, modifying existing routes, and fetching a route and clearing an entire
routing table or the routing cache.
1. View the main routing table with ip route show.
| # route -n (or, ip route show) |
2. Using ip route add to populate a routing table.
|
# ip route add192.168.1.0/24 dev eth0 # ip route add 192.168.2.252/32 dev eth1 src 192.168.2.110 # ip route add default via 192.168.1.254 |
3. Removing routes with ip route del.
| # ip route delete 192.168.2.252/32 dev eth1 src 192.168.2.180 |
4. Altering existing routes with ip route change.
| # ip route change default via 192.168.17.1 dev eth0 |
5. CIDR (Classless Inter-Domain Routing).
192.168.17.0/24 -- From 192.168.17.0 To 192.168.17.255
192.168.17.252/32 -- Only 192.168.17.252