[ltp] WiFi on T42 (routing issues with eth0 and eth1)

linux-thinkpad@linux-thinkpad.org linux-thinkpad@linux-thinkpad.org
Sat, 15 Jan 2005 16:55:17 -0800 (PST)


Hello,

--- morpheus <morpheus@post.harvard.edu> wrote:

> On Sat, 2005-01-15 at 08:24 -0800, ogjunk-linuxtp@yahoo.com wrote:
> > So I tried adding a new route/gateway for eth1 device (WiFi card):
> > 
> > # route add default gw 192.168.0.1 eth1
> > 
> > This gave me:
> > 
> > # 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
> > eth0
> > 192.168.0.0     *               255.255.255.0   U     0      0     
>   0
> > eth1
> > 169.254.0.0     *               255.255.0.0     U     0      0     
>   0
> > eth1
> > default         192.168.0.1     0.0.0.0         UG    0      0     
>   0
> > eth1
> > default         192.168.0.1     0.0.0.0         UG    0      0     
>   0
> > eth0
> > 
> Did you try # ping -I eth1 xxx.xxx.xxx.xxx

Yes, I did.  The DNS lookup goes through eth0, so the host name is
resolved to IP successfully.  Pinging the IP doesn't work either.

> First, I would check out
> http://linux-ip.net/html/linux-ip.html#basic-
> changing-default (scoll down to get table of contents).  This is a
> great
> document that teaches you all about IP networking on Linux.

Thanks, I checked it out.... but I'm afraid half of that stuff is too
advanced for me... :(

> Your basic problem is that the packet can only go over one interface.
> However, you have two routes defined as "default"...the "default"
> route
> catches all destinations not previously caught by other routes, so
> there is no way to decide which "default" route to use.

I think my problem is even more basic. :)
That is, if I take down eth0, bring up eth1, ensure the correct route,
I still can't ping.... can't even ping the router:

[root@localhost otis]# ifdown eth0

[root@localhost otis]# ifup eth1
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device eth1 ; Operation not supported.

[root@localhost otis]# 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
169.254.0.0     *               255.255.0.0     U     0      0        0
eth1
default         192.168.0.1     0.0.0.0         UG    0      0        0
eth1


The suspicious thing is that `route' 'hangs' before displaying
'default' route.  I believe this is typical when name lookup is not
working, and route -n indeed runs normally, confirming it's the lookup
that hangs.

So that's my first puzzle - eth0 is down, eth1 is up, the routing table
looks minimal and correct (isn't it?), yet I can't ping even my router:

[root@localhost otis]# ping 192.168.0.1 -I eth1
PING 192.168.0.1 (192.168.0.1) from 192.168.0.3 eth1: 56(84) bytes of
data.
>From 192.168.0.3 icmp_seq=1 Destination Host Unreachable

> Linux decides by shaking a magic 8 ball...
> Seriously, different implementations decide differently (first
> defined,
> last defined, lowest IF number, etc.) but there is no way to know for
> sure.  The one thing for sure is that when you define multiple routes
> with the same destination (such as "default") ONLY ONE default gw
> will be used, and the SAME one will be used every time.
> 
> There are several ways out of this situation:
> First, you could use the "Metric" parameter to prioritize your
> default routes:
> # route add default gw 192.168.0.1 metric 1 eth1
> # route add default gw 192.168.0.1 metric 2 eth0
> This would give priority to eth1, and when eth1 is not available,
> would use eth0.

That sounds _exactly_ as what I am trying to achieve.  If eth1 works,
use it, if not, try eth0.  It could go the other way around, too: if
eth0 works (I'm plugged in), use it.  If not, try eth1.

> Next, you could just take down eth0, (I think ifdown also removes the
> routes for you) and then all your packets would hit the default route
> for eth1.

This is what I just tried...but still no luck :(.  Here are the steps:

# take all NICs down, empty routing table
[root@localhost otis]# ifdown eth0
[root@localhost otis]# ifdown eth1
[root@localhost otis]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use
Iface

# Bring WiFi interface up, show routing table
[root@localhost otis]# ifup eth1
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device eth1 ; Operation not supported.

[root@localhost otis]# 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
169.254.0.0     *               255.255.0.0     U     0      0        0
eth1
default         192.168.0.1     0.0.0.0         UG    0      0        0
eth1

# Remote the default route, add default route for WiFi using metric 1
[root@localhost otis]# route del default
[root@localhost otis]# route add default gw 192.168.0.1 metric 1 eth1

# Bring up eth0, add default route for eth0 using metric 2
[root@localhost otis]# ifup eth0

Determining IP information for eth0... done.
RTNETLINK answers: No such process
[root@localhost otis]# route add default gw 192.168.0.1 metric 2 eth0
[root@localhost otis]# 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
eth0
169.254.0.0     *               255.255.0.0     U     0      0        0
eth0
default         192.168.0.1     0.0.0.0         UG    0      0        0
eth1
default         192.168.0.1     0.0.0.0         UG    1      0        0
eth1
default         192.168.0.1     0.0.0.0         UG    2      0        0
eth0

# Remove the extra default route (the one that didn't use metric)
[root@localhost otis]# route del default
[root@localhost otis]# 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
eth0
169.254.0.0     *               255.255.0.0     U     0      0        0
eth0
default         192.168.0.1     0.0.0.0         UG    1      0        0
eth1
default         192.168.0.1     0.0.0.0         UG    2      0        0
eth0

# Try pinging over eth0 (works)
[root@localhost otis]# ping 66.94.234.13 -I eth1
PING 66.94.234.13 (66.94.234.13) from 192.168.0.3 eth1: 56(84) bytes of
data.
>From 192.168.0.3 icmp_seq=0 Destination Host Unreachable

--- 66.94.234.13 ping statistics ---
3 packets transmitted, 0 received, +1 errors, 100% packet loss, time
2000ms
, pipe 2
[root@localhost otis]# ping 66.94.234.13 -I eth0
PING 66.94.234.13 (66.94.234.13) from 192.168.0.2 eth0: 56(84) bytes of
data.
64 bytes from 66.94.234.13: icmp_seq=0 ttl=51 time=92.0 ms
64 bytes from 66.94.234.13: icmp_seq=1 ttl=51 time=88.9 ms

--- 66.94.234.13 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 88.985/90.526/92.068/1.570 ms, pipe 2

# Take down eth0, try pinging over eth1 (no go)
[root@localhost otis]# ifdown eth0
[root@localhost otis]# ping 66.94.234.13 -I eth1
PING 66.94.234.13 (66.94.234.13) from 192.168.0.3 eth1: 56(84) bytes of
data.
>From 192.168.0.3 icmp_seq=1 Destination Host Unreachable


Ugggh :(
Don't my routing tables look correct now?
Maybe somebody with a similar setup can post their routing table....
I'm not the only one with a T42 here, am I? ;)

> Or, you could leave both interfaces up and on the same subnet, and
> just
> explicitly specify the interface to use in each application.  For
> example, when you ping you could use:
> # ping -I eth1 xxx.xxx.xxx.xxx
> This would force the ping over eth1.  Most applications and commands
> allow you to do this, but it seems pretty tedious for you.

Yeah, that wouldn't work for me - I'm using this T42 as an office
computer, workstation, and everything else.

> You could use different subnets...but this doesn't seem to be an
> option for you since your AP is on the same subnet as your wired LAN.

My AP's IP is: 192.168.0.1.  eth0 is 192.168.0.2 and eth1 is currently
192.168.0.3.  I could manually set the IP for eth1 to be, say,
192.168.1.3, if that would make things easier.

> There are two more options, in the "advanced" category:
> You could use "link aggregation".  This would treat BOTH eth0 and
> eth1
> as a single "virtual interface" and send packets over both.
> This is not trivial to set up, but information is available here:
> http://linux-ip.net/html/ether-bonding.html

> You could use iptables to "tag" your outbound traffic and then create
> routing rules to select the interface based on the tags. This is
> explained in:
> http://linux-ip.net/html/adv-multi-internet.html

Ajjjj.... thanks for this, but I'll leave these two as the last resort,
as going that route (pun intended) would take me a completely new land
that I'm afraid to step into right now.

> Let me know if you have questions getting this set up.

Well, let me thank you one more for your patience!  I really appreciate
it.  Would you (or anyone else) happen to have an example of a routing
table with both eth0 and eth1/wlan0 on the same subnet and going out
through the single gateway, so that packets go over either eth0 or
eth1, depending on whether the computer is plugged into the network or
is near an AP?

Thanks,
Otis