route is a traditional Unix/Linux command for viewing and manipulating the IP routing table. It displays the kernel routing table and allows administrators to add, delete, or modify routes that determine how network traffic is directed. While the newer ip route command offers more features, route remains a straightforward tool for basic routing operations.
📑 Table of Contents
Key Features
- View Routes – Display the current kernel routing table
- Add Routes – Create new static routes to networks or hosts
- Delete Routes – Remove existing routing entries
- Default Gateway – Configure the default route for internet access
- Host Routes – Set specific routes for individual hosts
- Metric Support – Assign priorities to multiple routes
Installation
# Debian/Ubuntu
sudo apt install net-tools
# RHEL/CentOS/Fedora
sudo dnf install net-tools
# Arch Linux
sudo pacman -S net-tools
Common Usage Examples
# Display routing table
route -n
# Add default gateway
sudo route add default gw 192.168.1.1
# Add network route
sudo route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.254
# Add host route
sudo route add -host 192.168.2.100 gw 192.168.1.254
# Delete a route
sudo route del -net 10.0.0.0 netmask 255.0.0.0
# Delete default gateway
sudo route del default gw 192.168.1.1
Use Cases
route is essential for configuring network paths, troubleshooting connectivity issues, setting up static routes, managing multi-homed systems, and understanding how traffic flows through your network.
Was this article helpful?