March 9, 2009

When was that route added ? ...

Recently, i was troubleshooting an issue with network routing on solaris and there was a need to find the time, when a particular network route was added. In minutes, i was able to figure a way to find this information ..

mdb ;)

Here is an example to illustrate the procedure:

root# date;route add -net 161.239.10.0 151.191.93.40
Mon Mar 9 17:31:04 EDT 2009
add net 161.239.10.0: gateway 151.191.93.40

root# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 151.191.93.1 UG 1 53559
151.191.93.0 151.191.93.16 U 1 12060 hme0
161.239.10.0 151.191.93.40 UG 1 0
224.0.0.0 151.191.93.16 U 1 0 hme0
127.0.0.1 127.0.0.1 UH 10 1558 lo0



root# mdb -k
Loading modules: [ unix genunix specfs dtrace zfs sd isp pcipsy ip hook neti sctp arp usba fcp fctl nca md audiosup cpc random crypto wrsmd fcip logindmux ptm ufs sppp nfs ipc ]
> ::netstat -r
Routing Table: IPv4
Address Destination Gateway Flags Ref Use Interface
3000448e8a8 0.0.0.0 151.191.93.1 UG 1 53572
3000448f598 151.191.93.0 151.191.93.16 U 1 12063 hme0
3000448fb58 224.0.0.0 151.191.93.16 U 1 0 hme0
3000448fe38 127.0.0.1 127.0.0.1 UH 10 1558 lo0
3000681bb60 161.239.10.0 151.191.93.40 UG 1 0
>
> 3000681bb60::print -t ire_t ire_create_time
time_t ire_create_time = 2009 Mar 9 17:31:04
Bingo !!! thats one more great reason - why i love solaris ;-) Its easy to debug, its stable and i love it ....

I have put together a small script to print "netstat -rn" with creation time for every route - netstat_date.sh
root# ./netstat_date.sh
Routing Table:
Address Destination Gateway Flags Ref Use Interface Creation date/time
3000448e8a8 0.0.0.0 151.191.93.1 UG 1 64832 2009 Feb 24 12:33:33
3000448f598 151.191.93.0 151.191.93.16 U 1 13988 hme0 2009 Feb 24 12:34:35
3000448fb58 224.0.0.0 151.191.93.16 U 1 0 hme0 2009 Feb 24 12:34:35
3000448fe38 127.0.0.1 127.0.0.1 UH 10 1786 lo0 2009 Feb 24 12:34:35
3000681bb60 161.239.10.0 151.191.93.40 UG 1 0 2009 Mar 9 17:31:04