Linux Route/Loopback Problem - 2 STAs on same machine

Kristian Hoffmann khoff
Thu Dec 19 13:49:35 PST 2002


If you have the iproute2 utilities, run "ip route show table local".
Those routes are visited first, so your host routes are never reached.

You can delete the routes in the local table that tell your machine how to
get to its own addresses, and then it will use the host routes you
specify.  The packets will reach the AP and then be sent back to your
other interface.  Since you delete the local routes though, when the other
interface receives the packets, they will be dropped because it won't know
how to route to itself.

In other words, this is just a bad idea.  Get another machine to test
with. :-)

-Kristian

On Thu, 19 Dec 2002, David C Wang wrote:

> Hi,
>
> I've been unable to resolve this problem for a while.  Hopefully
> someone can help me out.  I've already posted this question to
> comp.os.linux.networking with no luck.  I'll probably also post
> to linux-wlan.
>
> I have 2 wireless interfaces on the *same machine* wlan0 and wlan1
> (linux-wlan), and am trying to test an ap (hostap) by having both
> interfaces wlan0 and wlan1 speak to each other via the ap.  Both
> interfaces associate just fine, but i'm having trouble setting up the
> linux routes so that the stas can ping each other.  I'm hoping that
> someone on this list has tried this before.
>
> It seems that linux is ignoring the routing table for local network
> devices, and forcing the route through the loopback device.  Is there
> any way to get around this?
>
> Here's a description of the problem.  On the same computer, I have
> interfaces wlan0 (192.168.0.10) and wlan1 (192.168.0.11).  I want to
> ping from wlan0 to wlan1, and make the packet physically hit the
> radio, instead of going through the loopback netdevice.
>
> I enable ip_forwarding
>   echo "1" > /proc/sys/net/ipv4/ip_forward
> I clear the kernel routing cache
>   echo "1" > /proc/sys/net/ipv4/route/flush
>
> Then, I modify my routing tables to say that packets going to
> 192.168.0.10 (wlan0) should exit through the wlan1 netdevice, and vice
> versa:
>
>   dave:/home/dave# route add -host 192.168.0.11 dev wlan0
>   dave:/home/dave# route add -host 192.168.0.10 dev wlan1
>   dave:/home/dave# route -n
>   Kernel IP routing table
>   Destination  Gateway      Genmask         Flags Metric Ref  Use Iface
>   192.168.0.10 0.0.0.0      255.255.255.255 UH    0      0      0 wlan1
>   192.168.0.11 0.0.0.0      255.255.255.255 UH    0      0      0 wlan0
>   10.1.1.0     0.0.0.0      255.255.255.0   U     0      0      0 eth0
>   0.0.0.0      10.1.1.254   0.0.0.0         UG    0      0      0 eth0
>
> Then I ping 192.168.0.10, which should get routed through the second
> netdevice wlan1, but the packet still goes through the loopback
> netdevice, instead of directly out the physical device.
>
>   dave:/home/dave#  ping -c 1 192.168.0.10
>   PING 192.168.0.10 (192.168.0.10): 56 data bytes
>   64 bytes from 192.168.0.10: icmp_seq=0 ttl=64 time=0.0 ms
>   --- 192.168.0.10 ping statistics ---
>   1 packets transmitted, 1 packets received, 0% packet loss
>   round-trip min/avg/max = 0.0/0.0/0.0 ms
>
> To verify, I check the Kernel Routing Cache, which indeed shows that
> pings to 192.68.0.10 will go through the loopback device.
>
>   dave:/home/dave# route -nC|grep -v 10
>   Kernel IP routing cache
>   Source        Destination   Gateway       Flags Metric Ref  Use Iface
>   192.168.0.11  192.168.0.11  192.168.0.11  l     0      0      0 lo
>   192.168.0.11  192.168.0.11  192.168.0.11  l     0      0      0 lo
>   192.168.0.10  192.168.0.10  192.168.0.10  l     0      0      1 lo
>   192.168.0.10  192.168.0.10  192.168.0.10  l     0      0      1 lo
>
> I try again by modifying the routing tables to include a gateway for
> each device.  But I get the same result, and the same output from the
> kernel routing cache.
>
>   da:/home/dave# route add -host 192.168.0.11 gw 192.168.0.10 dev wlan0
>   da:/home/dave# route add -host 192.168.0.10 gw 192.168.0.11 dev wlan1
>   dave:/home/dave# route -n
>   Kernel IP routing table
>   Destination  Gateway      Genmask         Flags Metric Ref Use Iface
>   192.168.0.10 192.168.0.11 255.255.255.255 UGH   0      0     0 wlan1
>   192.168.0.11 192.168.0.10 255.255.255.255 UGH   0      0     0 wlan0
>   10.1.1.0     0.0.0.0      255.255.255.0   U     0      0     0 eth0
>   0.0.0.0      10.1.1.254   0.0.0.0         UG    0      0     0 eth0
>
> I am also aware of the "local" routing table accessible through the
> old linux-2.2 "iproute2" interface.
>
>   dave:/home/dave# ip route show table local|grep 192
>   broadcast 192.168.0.255 dev wlan0  proto kernel  scope link  src
> 192.168.0.10
>   broadcast 192.168.0.255 dev wlan1  proto kernel  scope link  src
> 192.168.0.11
>   local 192.168.0.11 dev wlan1  proto kernel  scope host  src
> 192.168.0.11
>   local 192.168.0.10 dev wlan0  proto kernel  scope host  src
> 192.168.0.10
>   broadcast 192.168.0.0 dev wlan0  proto kernel  scope link  src
> 192.168.0.10
>   broadcast 192.168.0.0 dev wlan1  proto kernel  scope link  src
> 192.168.0.11
>
> So I try to swap the sources also in this table for each device
>
>   dave:/home/dave# ip route change table local local 192.168.0.10 dev
> wlan1 \
> 		  proto kernel scope host src 192.168.0.11
>   dave:/home/dave# ip route change table local local 192.168.0.11 dev
> wlan0 \
> 		  proto kernel scope host src 192.168.0.10
>
> And this is what i get.
>
>   dave:/home/dave# ip route show table local|grep 192
>   broadcast 192.168.0.255 dev wlan0  proto kernel  scope link  src
> 192.168.0.10
>   broadcast 192.168.0.255 dev wlan1  proto kernel  scope link  src
> 192.168.0.11
>   local 192.168.0.11 dev wlan0  proto kernel  scope host  src
> 192.168.0.10
>   local 192.168.0.10 dev wlan1  proto kernel  scope host  src
> 192.168.0.11
>   broadcast 192.168.0.0 dev wlan0  proto kernel  scope link  src
> 192.168.0.10
>   broadcast 192.168.0.0 dev wlan1  proto kernel  scope link  src
> 192.168.0.11
>
> Again, when i try to ping it goes through the loopback device.  The
> routing cache verifies this again.
>
> It seems that linux is ignoring the routing table for local network
> devices, and forcing the route through the loopback device.  Is there
> any way to get around this?
>
> thanks,
> -dave
> dave at davidwang dot c*m
>
>
>
>
>
> _______________________________________________
> HostAP mailing list
> HostAP at shmoo.com
> http://lists.shmoo.com/mailman/listinfo/hostap
>





More information about the Hostap mailing list