[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Fwd: Re: nslu2: two devices: one by default]




--- Begin Message ---
Hi,

I have follow your comments and for now I wrote a python script [http://github.com/somenxavi/misc/blob/master/change-routing-script/cable-ini.py] that I run every minute in my system. It essentially see if ethernet cable is present. If it's nothing do. If it isn't (unplugged), then it modify the routing table (via ip route) for put wlan0 (instead eth0) as my prefered route device.

But it does not works: when I unplugged the cable, then the script does not modify the routing table (see the log of my system [http://github.com/somenxavi/misc/blob/master/change-routing-script/log.txt]).

Can you see it? How can I change the script for doing what I want?

Thanks,
Xan.




En/na Lennart Sorensen ha escrit:
On Thu, Dec 10, 2009 at 05:03:40PM +0100, Xan wrote:
Hi,

I have now this route table:

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
localnet        *               255.255.0.0     U     0      0        0 eth0
localnet * 255.255.0.0 U 0 0 0 wlan0 default 172.26.0.1 0.0.0.0 UG 0 0 0 wlan0
default         172.26.0.1      0.0.0.0         UG    0      0        0 eth0

(with ip route I get:
172.26.0.0/16 dev eth0  proto kernel  scope link  src 172.26.0.2
172.26.0.0/16 dev wlan0  proto kernel  scope link  src 172.26.0.3
default via 172.26.0.1 dev wlan0
default via 172.26.0.1 dev eth0 )

and I want to get that:

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
localnet        *               255.255.0.0     U     0      0        0 eth0
default         172.26.0.1      0.0.0.0         UG    0      0        0 eth0


Can I get that with the following command? Please confirm:

ip route del default via 172.26.0.1 dev wlan0
ip route del 172.26.0.1/16 dev wlan0  proto kernel  scope link  src 172.26.0.1

and
ip route add 172.26.0.1/16 dev eth0  proto kernel  scope link  src 172.26.0.1
ip route add default via 172.26.0.1 dev eth0

?

Is it correct?

Should work, or you could do:

ip route replace 172.26.0.1/16 dev eth0  proto kernel  scope link  src 172.26.0.1
ip route replace default via 172.26.0.1 dev eth0

instead of del and add.




--- End Message ---

Reply to: