Re: nslu2: two devices: one by default
En/na Lennart Sorensen ha escrit:
On Sat, Oct 31, 2009 at 03:19:22PM +0100, Xan wrote:
En/na Lennart Sorensen ha escrit:
On Fri, Oct 30, 2009 at 05:32:09PM +0100, Xan wrote:
Hi,
Perhaps it's a too much simple question, but I don't know what
achieve that: In nslu2 I have two network devices: eth0 and wlan0
(wifi). I just want that:
- nslu2 tries if eth0 is plugged. If it's, then all network
connection were established via eth0
- if eth0 is unplugged, then all network connection were established
via wlan0.
Now the first is done, but when I unplugged the eth0 I can't reach
the system (all packets loose)
Anyone could help me? I suspect that I have to touch the route table.
Is it true?
My route table is:
# 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
wlan0 has static ip 172.26.0.3 and eth0 has static ip 172.26.0.2
172.26.0.1 is the router (what has internet connectivity). I just
want to have local network connections between all other devices and
my nslu2.
Linux in general does not deal with ignoring routes just because an
interface is down. Unix like systems never do. Routers do.
But I can reach other boxes with the same network and different ip?
What's the easiest solution to achieve that when I unplug eth0 I can
reach nslu2 via wlan0?
Well in your case it appears that right now eth0 is the first choice for
reaching the local network, and wlan0 is the first choice for default
route, although since the default route uses a gateway on your local
network, it may still use eth0 for that. If eth0 goes down, you won't
be able to reach the local network, since the route in use goes to eth0
and it is down.
I use a small kernel patch that makes the kernel delete local network
routes whenever a link is down, and readd it when the link comes back.
That solves the problem. I manage any additional static routes
(including default route) through zebra (quagga route deamon) with link
detect enabled.
[....]
First of all, I'm impressed. Wow!. Thanks for this great and comprensive
answer. Now I understand the problem I have.
Although I thank you the patch I will not patch the kernel because
patching kernels are not supported and really unmantained (the security
advisories do that I have to recompile the kernel). The ideal situation
is that your patch will be included in debian repository as whole kernel
and the more realistic situation is that it will be included only as a
patch, and with apt-get we could have it ;-)
Other than patching the kernel to change the behaviour to be more router
like though, about the best you can do is have a cron job or daemon
check the link state, and delete the route if the link goes down, and
add it back when the link returns. I consider that ugly and fragile
though.
Sorry but I have no technical skills for doing that :-(. A more simple
script were a script for switching the route table for nslu2 connects
_firstly_ via some device all the time:
for example:
# script eth0
produces a route table like:
# 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 eth0
default 172.26.0.1 0.0.0.0 UG 0 0 0
wlan0
and
# script wlan0
produces
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
localnet * 255.255.0.0 U 0 0 0
wlan0
localnet * 255.255.0.0 U 0 0 0 eth0
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
But another way I have no tech skills for doing that. The route command
is too much complicated for me. Would you like to help me in that?
Typically, I enter via ssh in my slug in 172.26.0.2 (the eth0 static
ip), I run "script wlan0" and it swicthes to wlan0. So I unplugged the
eth0 and then I connected ssh via 172.26.0.3 (the wlan0 static ip)
(without the cable of eth0). What's the magical solution I want ;-)
Thanks a lot,
Xan.
Reply to: