🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

ip route Command

Intermediate Networking man(1)

Show and manipulate the routing table

👁 11 views 📅 Updated: Mar 15, 2026
SYNTAX
ip route [COMMAND]

What Does ip route Do?

ip route displays and manages the kernel routing table. It shows how the system decides where to send network packets — which interface and gateway to use for each destination network.

The routing table is fundamental to networking. Every packet sent by the system is matched against routing rules to determine the next hop (gateway) and outgoing interface.

ip route replaces the older route command. It is part of the iproute2 package and provides comprehensive routing management including policy routing, multipath, and VRFs.

Options & Flags

OptionDescriptionExample
show Display routing table ip route show
get Show route for specific destination ip route get 8.8.8.8
add Add a route sudo ip route add 10.0.0.0/8 via 192.168.1.1
del Delete a route sudo ip route del 10.0.0.0/8
replace Replace or add a route sudo ip route replace default via 192.168.1.1

Practical Examples

#1 Show routing table

Displays all routes in the routing table.
$ ip route show
Output: default via 192.168.1.1 dev eth0 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100 10.0.0.0/8 via 192.168.1.254 dev eth0

#2 Check route for destination

Shows exactly which route would be used to reach 8.8.8.8.
$ ip route get 8.8.8.8
Output: 8.8.8.8 via 192.168.1.1 dev eth0 src 192.168.1.100

#3 Add static route

Routes all 10.x.x.x traffic through 192.168.1.254.
$ sudo ip route add 10.0.0.0/8 via 192.168.1.254

#4 Change default gateway

Sets the default gateway.
$ sudo ip route replace default via 192.168.1.1 dev eth0

#5 Delete route

Removes a static route.
$ sudo ip route del 10.0.0.0/8

Tips & Best Practices

ip route get is very useful: ip route get IP shows exactly which route, gateway, and interface will be used. Great for debugging.
Not persistent: ip route changes are lost on reboot. For permanent routes, configure /etc/netplan/ or /etc/network/interfaces.
Replaces route command: ip route replaces the legacy route command. route → ip route show. route add → ip route add.

Frequently Asked Questions

How do I see the routing table?
ip route show displays all routes. ip route get DESTINATION shows the specific route for a destination.
How do I change the default gateway?
sudo ip route replace default via GATEWAY_IP dev INTERFACE. Changes are temporary until reboot.
How do I add a static route permanently?
Add to /etc/netplan/*.yaml (Ubuntu) or /etc/sysconfig/network-scripts/ (RHEL). ip route add is temporary.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →