route vs ip route: Key Differences for Static Routing Configuration in Linux Networking


2 views

The route command belongs to the legacy net-tools package (deprecated in most modern distributions), while ip route is part of the iproute2 suite - the current standard for Linux networking.

While both commands manipulate routing tables, their implementation differs significantly:

# Traditional route command
route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.0.0.1 dev eth0

# Modern ip route equivalent
ip route add 192.168.1.0/24 via 10.0.0.1 dev eth0
  • Syntax: iproute2 uses more consistent and flexible CIDR notation
  • Features: iproute2 supports advanced routing (policy routing, multiple tables)
  • Output format: iproute2 provides more detailed and machine-parsable output

Adding a default route with both methods:

# Legacy method
route add default gw 192.168.1.1

# Recommended method
ip route add default via 192.168.1.1

Viewing routing tables:

# Legacy (limited information)
route -n

# Modern (detailed view)
ip route show

The iproute2 suite offers several advantages:

  • Better support for modern networking features (VLANs, tunnels)
  • More consistent syntax across subcommands
  • Active maintenance and development
  • Better integration with other Linux networking components

Common operations translated:

# Delete route
route del -net 10.0.0.0 netmask 255.0.0.0
ip route del 10.0.0.0/8

# Add host route
route add -host 192.168.1.100 dev eth0
ip route add 192.168.1.100/32 dev eth0

When having routing issues:

# Check all routing tables (including main and custom)
ip route show table all

# Get detailed info about a specific route
ip route get 8.8.8.8

Remember that ip route changes are not persistent across reboots unless saved through distribution-specific mechanisms.


In Linux networking, we've seen an evolution of tools for managing routes. The traditional route command comes from the net-tools package, while ip route is part of the newer iproute2 suite. Understanding their differences is crucial for proper network configuration.

route command (net-tools):

# Display current routing table
route -n

# Add a static route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.0.0.1

# Delete a route
route del -net 192.168.1.0 netmask 255.255.255.0

ip route command (iproute2):

# Display routing table
ip route show

# Add a static route
ip route add 192.168.1.0/24 via 10.0.0.1

# Delete a route
ip route del 192.168.1.0/24

The ip command suite offers several advantages:

  • More consistent syntax across subcommands
  • Better handling of modern networking features
  • Direct kernel interaction without legacy abstractions
  • Continued maintenance and updates

Converting from legacy route to ip route:

# Legacy route command
route add default gw 192.168.1.1

# Equivalent ip route command
ip route add default via 192.168.1.1

While iproute2 is preferred, some scenarios might still require the legacy tool:

  • Older systems without iproute2 installed
  • Scripts that haven't been updated
  • Certain embedded systems with limited packages

The ip route command supports more advanced configurations:

# Add route with metric
ip route add 192.168.1.0/24 via 10.0.0.1 metric 100

# Add route for specific interface
ip route add 192.168.1.0/24 dev eth0

# Policy-based routing
ip route add table 100 default via 10.0.0.2

Remember that these commands make temporary changes. For persistent routes, you'll need to:

  • Edit /etc/network/interfaces (Debian/Ubuntu)
  • Use /etc/sysconfig/network-scripts/ (RHEL/CentOS)
  • Create systemd networkd configuration files
  • Use distribution-specific network management tools