How to Monitor Routing Table on Linux Server - Complete Network Routing Tracking Guide

Are you wondering how to check and monitor the routing table on your Linux server? Need to detect routing configuration changes and ensure proper network connectivity? This comprehensive guide shows you multiple methods to monitor routin...

Last updated: 2025-11-17

How to Monitor Routing Table on Linux Server - Complete Network Routing Tracking Guide

Are you wondering how to check and monitor the routing table on your Linux server? Need to detect routing configuration changes and ensure proper network connectivity? This comprehensive guide shows you multiple methods to monitor routing tables, detect routing changes automatically, troubleshoot network routing issues, and maintain network stability on your Linux server.

Why Monitoring Routing Table Matters

The routing table determines how network packets are forwarded on your Linux server. It defines which network interfaces packets use, which gateways handle traffic, and how routes are prioritized. When routing configuration is incorrect or changes unexpectedly, your server can lose network connectivity, applications can fail to reach remote hosts, and services can become unavailable. Learning how to monitor routing tables helps you detect configuration changes immediately, troubleshoot network issues quickly, maintain network stability, and ensure proper packet forwarding. Regular routing table monitoring prevents connectivity problems and helps you maintain reliable network services.

Method 1: Check Routing Table with ip route Command

The ip route command is the modern tool for checking routing tables on Linux servers. This command provides detailed routing information and is the recommended method on modern Linux distributions.

View Complete Routing Table

To see all routes in the routing table:

# Show all routes
ip route show

# Show routing table in numeric format
ip -n route show

# Show routing table with more details
ip route show table all

# Show routing table for specific address family
ip -4 route show
ip -6 route show

The ip route show command displays all routes including default routes, network routes, and host routes.

View Default Route

To see the default gateway route:

# Show default route
ip route show default

# Show default route with details
ip route get default

# Show default gateway IP
ip route | grep default | awk '{print $3}'

# Test default route
ip route get 8.8.8.8

View Routes by Network Interface

To see routes for specific network interfaces:

# Show routes for specific interface
ip route show dev eth0

# Show routes for all interfaces
ip route show | grep -E "^[0-9]"

# Show interface-specific routes
for iface in $(ip link show | grep -E "^[0-9]" | awk '{print $2}' | tr -d ':'); do
  echo "Routes for $iface:"
  ip route show dev $iface
done

Method 2: Check Routing Table with netstat Command

The netstat command provides an alternative method for viewing routing tables, though it's considered legacy on modern Linux systems.

View Routing Table with netstat

To see routing table using netstat:

# Show routing table
netstat -rn

# Show routing table with hostnames
netstat -r

# Show routing table for IPv4
netstat -rn -4

# Show routing table for IPv6
netstat -rn -6

The -r flag shows routing table, while -n displays addresses in numeric format (faster, no DNS lookups).

View Default Route with netstat

To see default gateway:

# Show default route
netstat -rn | grep "^0.0.0.0"

# Show default gateway IP
netstat -rn | grep "^0.0.0.0" | awk '{print $2}'

# Show default route with interface
netstat -rn | grep "^0.0.0.0" | awk '{print $2, $8}'

Method 3: Check Routing Table with route Command

The route command is another legacy tool for viewing routing tables, available on many Linux systems.

View Routing Table with route

To see routing table using route command:

# Show routing table
route -n

# Show routing table with hostnames
route

# Show kernel routing table
route -n -e

# Show routing cache (if available)
route -Cn

View Specific Routes

To filter routes:

# Show default route
route -n | grep "^0.0.0.0"

# Show routes for specific network
route -n | grep "192.168.1.0"

# Show routes via specific gateway
route -n | grep "192.168.1.1"

Method 4: Advanced Routing Table Analysis

Beyond basic checks, you can use advanced techniques to analyze routing tables more effectively.

Check Route Metrics

To see route priorities and metrics:

# Show routes with metrics
ip route show | grep -E "metric|pref"

# Show route metrics for specific route
ip route get 8.8.8.8

# Compare route metrics
ip route show | awk '{print $1, $5, $7, $9}'

Check Route Sources

To see where routes come from:

# Show route sources
ip route show table all | grep -E "proto|src"

# Show static routes
ip route show proto static

# Show routes from specific source
ip route show proto kernel

Analyze Route Changes

To detect routing table changes:

# Save current routing table
ip route show > /tmp/routes-$(date +%Y%m%d).txt

# Compare with previous routing table
diff /tmp/routes-old.txt /tmp/routes-new.txt

# Detect default route changes
OLD_DEFAULT=$(grep default /tmp/routes-old.txt)
NEW_DEFAULT=$(ip route show default)
if [ "$OLD_DEFAULT" != "$NEW_DEFAULT" ]; then
  echo "Default route changed"
fi

Method 5: Automated Routing Table Monitoring with Zuzia.app

Manually checking routing tables works for occasional audits, but for production Linux servers, you need automated monitoring that alerts you when routing configurations change or routes become unavailable. Zuzia.app provides comprehensive routing table monitoring through scheduled command execution.

Setting Up Automated Routing Table Monitoring

  1. Add Scheduled Task in Zuzia.app Dashboard

    • Navigate to your server in Zuzia.app
    • Click "Add Scheduled Task"
    • Choose "Command Execution" as the task type
  2. Configure Routing Table Check Command

    • Enter command: ip route show
    • Set execution frequency: Every hour or every few hours
    • Configure alert conditions: Alert when routing table changes
    • Set up comparison with previous runs to detect changes
  3. Set Up Notifications

    • Choose notification channels (email, webhook, Slack, etc.)
    • Configure alert thresholds (e.g., alert if default route changes)
    • Set up escalation rules for critical route changes
    • Configure different alert levels for different route types

Monitor Specific Routes

For critical routes, create dedicated monitoring tasks:

# Monitor default route
ip route show default

# Monitor specific network route
ip route show 192.168.1.0/24

# Monitor gateway availability
ping -c 3 $(ip route show default | awk '{print $3}')

Zuzia.app stores all command outputs in its database, allowing you to track routing tables over time, identify routing changes, and detect routing problems before they cause connectivity issues.

Method 6: Routing Table Troubleshooting

When troubleshooting network issues, routing table analysis is essential.

Verify Default Gateway

To check if default gateway is configured correctly:

# Show default route
ip route show default

# Test default gateway connectivity
ping -c 3 $(ip route show default | awk '{print $3}')

# Check if default gateway is reachable
ip route get 8.8.8.8

Check Route Conflicts

To identify routing conflicts:

# Show all routes for specific destination
ip route get 192.168.1.100

# Show routes with same destination
ip route show | grep "192.168.1.0"

# Check for duplicate routes
ip route show | sort | uniq -d

Verify Route Metrics

To check route priorities:

# Show routes sorted by metric
ip route show | sort -k5 -n

# Show route with lowest metric (highest priority)
ip route show | sort -k5 -n | head -1

# Compare route metrics
ip route show | awk '{print $1, $5, $7}' | sort -k2 -n

Real-World Use Cases for Routing Table Monitoring

Network Configuration Change Detection

For security and compliance, detect unauthorized routing changes:

# Monitor routing table
ip route show

# Compare with baseline
diff /etc/baseline-routes.txt <(ip route show)

# Alert on changes
if ! diff -q /etc/baseline-routes.txt <(ip route show) > /dev/null; then
  echo "Routing table changed"
fi

Network Troubleshooting

For network connectivity issues, analyze routing:

# Check routing to specific destination
ip route get 8.8.8.8

# Verify default gateway
ip route show default

# Check all routes
ip route show | grep -v "^default"

Multi-Homed Server Monitoring

For servers with multiple network interfaces:

# Show routes per interface
for iface in $(ip link show | grep -E "^[0-9]" | awk '{print $2}' | tr -d ':'); do
  echo "Routes for $iface:"
  ip route show dev $iface
done

# Check default routes per interface
ip route show | grep default

Best Practices for Routing Table Monitoring

1. Monitor Routing Table Regularly

Check routing tables every hour or every few hours. Routing table changes are typically infrequent but important to detect quickly. Use Zuzia.app automated monitoring to check routing tables continuously without manual intervention.

2. Track Routing Table Changes

Monitor routing table changes over time to identify when changes occur. Compare routing tables before and after network configuration changes to verify changes were applied correctly. Use Zuzia.app's historical data to track routing table history and identify change patterns.

3. Monitor Default Route Specifically

The default route is critical for network connectivity. Monitor it separately and alert immediately if it changes. Test default gateway connectivity regularly to ensure it's reachable and functioning.

4. Document Expected Routes

Maintain documentation about expected routing table entries. Document which routes should exist, which gateways should be used, and which routes should be avoided. Update documentation when routing configuration changes.

5. Test Route Connectivity

Don't just monitor routing table entries - test that routes actually work. Use ping or ip route get to verify routes are functional and gateways are reachable.

Troubleshooting Common Routing Issues

Default Route Missing

If default route is missing:

# Check if default route exists
ip route show default

# Check routing table
ip route show

# Check network interfaces
ip link show

# Check network configuration
ip addr show

Default Gateway Not Reachable

If default gateway is not responding:

# Check default gateway IP
DEFAULT_GW=$(ip route show default | awk '{print $3}')
echo "Default gateway: $DEFAULT_GW"

# Test gateway connectivity
ping -c 3 $DEFAULT_GW

# Check ARP table for gateway
arp -n $DEFAULT_GW

# Check route to gateway
ip route get $DEFAULT_GW

Route Conflicts

If routes conflict:

# Show all routes for destination
ip route get 192.168.1.100

# Show routes with metrics
ip route show | grep "192.168.1.0"

# Check route priorities
ip route show | sort -k5 -n

FAQ: Common Questions About Monitoring Routing Tables

How often should I check routing table on my Linux server?

We recommend checking routing table every hour or every few hours. Routing table changes are typically infrequent but important to detect quickly. For critical environments or servers with dynamic routing, you might check more frequently. Use Zuzia.app automated monitoring to check routing tables continuously without manual intervention.

What should I do when routing table changes?

When routing table changes, first verify that the change was authorized (part of planned network configuration updates). Then test network connectivity to ensure the new routing works correctly. Check system logs for any routing-related errors or warnings. If the change was unexpected, investigate the cause and verify network connectivity before continuing operations.

Can I monitor specific routes?

Yes, you can monitor specific routes using commands like ip route show 192.168.1.0/24 or ip route show default. Create separate monitoring tasks in Zuzia.app for critical routes. Filter routes using grep: ip route show | grep "192.168.1.0".

How do I see route metrics and priorities?

Route metrics indicate route priority - lower metrics mean higher priority. Use ip route show to see metrics (shown as metric X in output). Routes are selected based on longest prefix match first, then by lowest metric. Monitor metrics to understand route selection behavior.

Why is monitoring routing table important?

Monitoring routing table helps ensure proper network connectivity, detect unauthorized configuration changes, troubleshoot network issues, maintain reliable packet forwarding, and comply with network security policies. Routing failures can cause widespread connectivity problems, so tracking routing configuration is essential for maintaining system availability.

How do I compare routing tables across multiple servers?

Use Zuzia.app to monitor routing tables across multiple servers simultaneously. Each server executes routing checks independently, and all results are stored in Zuzia.app's database for centralized comparison and analysis. You can view routing tables for all servers in a single dashboard and identify servers with incorrect or mismatched routing configurations.

Does Zuzia.app track routing table changes over time?

Yes, Zuzia.app stores all command outputs in its database, allowing you to track routing tables over time and identify when routing configurations change. You can view historical data to see routing table changes, identify change patterns, and verify that routing updates were applied correctly. This helps you maintain compliance with network policies and troubleshoot routing issues proactively.

We use cookies to ensure the proper functioning of our website.