Tuesday, September 30, 2008

route - show / manipulate the IP routing table

Actually I'm using a Debian Lenny with kernel $(uname -r) 2.6.22-3-686.
Sometimes I'm surfing the web through my job's wired connection and I get an error like "Page not found etc. blah blah blah". Why? The answer is my routing table changes automatically when a non-protected wireless connection is found. I don't need wireless connection when I'm working... let's take a look to my corrupted routing table:


berlin:/home/parra# route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth1
default 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0
default 192.168.0.254 0.0.0.0 UG 0 0 0 eth1



First of all I need to shut down the wireless interface:


berlin:/home/parra# ifdown wlan0


After this I need to remove the lines with wlan0 interface in the table, the command is (2 times because I have 2 interfaces):


berlin:/home/parra# route del default


berlin:/home/parra# route del default


Now I have this routing table:

berlin:/home/parra# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
link-local * 255.255.0.0 U 0 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth1



I need to remove the second line cause it's using wlan0 interface:


berlin:/home/parra# route del -net 192.168.0.0 netmask 255.255.255.0 dev wlan0


After all this boring stuff... I need to restore the default gateway for my wired connection:


berlin:/home/parra# route add default gw 192.168.0.254


berlin:/home/parra# route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
link-local * 255.255.0.0 U 1000 0 0 eth1
default 192.168.0.254 0.0.0.0 UG 0 0 0 eth1



It's done. Parra.

No comments: