-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux IP Routing
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to IP routing on Linux, covering Arch Linux, CachyOS, and other distributions including routing tables, static routes, and network routing configuration.
List routes:
# List routes
ip route show
# Or
route -n
# Show routing table
ip route list
# Show default route
ip route show defaultWhat it shows:
- Destination networks
- Gateway addresses
- Interface used
- Route metrics
Route format:
192.168.1.0/24 via 192.168.1.1 dev eth0
Components:
- 192.168.1.0/24: Destination network
- via 192.168.1.1: Gateway (router)
- dev eth0: Network interface
Add static route:
# Add route
sudo ip route add 192.168.2.0/24 via 192.168.1.1
# Add with interface
sudo ip route add 192.168.2.0/24 via 192.168.1.1 dev eth0
# Add default route
sudo ip route add default via 192.168.1.1What it does:
- Routes traffic for specific network through gateway
- Useful for multiple networks or VPNs
- Temporary (lost on reboot)
Remove route:
# Delete route
sudo ip route del 192.168.2.0/24
# Delete default route
sudo ip route del defaultMake permanent (systemd-networkd):
# Create route file
sudo vim /etc/systemd/network/route-eth0Add:
[Route]
Destination=192.168.2.0/24
Gateway=192.168.1.1
Using NetworkManager:
# Edit connection
nmcli connection edit "Wired connection 1"
# Add route
set ipv4.routes "192.168.2.0/24 192.168.1.1"
save
activateSet route priority:
# Add route with metric
sudo ip route add 192.168.2.0/24 via 192.168.1.1 metric 100
# Lower metric = higher priorityCheck routing:
# Check routes
ip route show
# Test connectivity
ping -r 192.168.2.1
# Trace route
traceroute 192.168.2.1
# Check gateway
ip route get 192.168.2.1Fix default route:
# Add default route
sudo ip route add default via 192.168.1.1
# Check gateway
ip route show defaultThis guide covered IP routing for Arch Linux, CachyOS, and other distributions, including routing tables, static routes, and configuration.
- Networking - Network setup
- Network Utilities - Network tools
- ArchWiki Routing: https://wiki.archlinux.org/title/Network_configuration#Routing_table
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.