Three methods for displaying the current route table on linux

[root@spacewalk ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.56.0    0.0.0.0         255.255.255.0   U         0 0          0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1
0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 eth0

[root@spacewalk ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.56.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth1
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0

[root@spacewalk ~]# cat /proc/net/route
Iface Destination Gateway  Flags RefCnt Use Metric Mask     MTU Window IRTT
eth0  0002000A    00000000 0001  0      0   0      00FFFFFF 0   0      0 
eth1  0038A8C0    00000000 0001  0      0   0      00FFFFFF 0   0      0
eth0  0000FEA9    00000000 0001  0      0   1002   0000FFFF 0   0      0 
eth1  0000FEA9    00000000 0001  0      0   1003   0000FFFF 0   0      0
eth0  00000000    0202000A 0003  0      0   0      00000000 0   0      0

Command to determine which route will be used for a certain destination

ip route get to 10.10.10.0
ip route get to 192.168.0

Simple bash script to simulate network failure

#!/bin/bash

ethcard=eth0
MAXWAITTIME=30
NUMBEROFRUNS=100
WAITTIME=10 #initial value over written by random_delay()

random_delay() {
 MAXTIME=30  #5 Minutes
 delay=$RANDOM
 let "delay %= $MAXWAITTIME"
 WAITTIME=$delay
}

random_delay

for i in `seq 1 $NUMBEROFRUNS`
do
  random_delay
    echo "bringing $ethcard Offline for $WAITTIME seconds"
      ifdown $ethcard;  sleep $WAITTIME
  random_delay
    echo "bringing $ethcard Online for $WAITTIME seconds"
      ifup $ethcard ;  sleep $WAITTIME
done

Determine the routes a packet will take on a linuix server

ip route get to 8.8.8.8


8.8.8.8 via 192.168.0.1 dev eth0  src 192.168.0.6 
cache