[LEDE-DEV] Routing two interfaces on same subnet
Baptiste Jonglez
baptiste at bitsofnetworks.org
Mon Jul 4 14:53:11 PDT 2016
On Mon, Jul 04, 2016 at 10:54:27PM +0200, Baptiste Clenet wrote:
> Hi Wang,
> Thank for your answer. May you explain how to do that?
> I think this should work.
The general idea would be:
default via 192.168.0.1 dev wlan0 src 192.168.0.12 metric 300
default via 192.168.1.1 dev eth0 src 192.168.1.42 metric 200
where the route with the lowest metric is used. If it disappears, the
remaining route is used instead.
You should be able to do that on LEDE/OpenWRT, see the metric option here:
https://wiki.openwrt.org/doc/uci/network#ipv4_routes
The problem is that, in your case, it probably won't work, because:
1) you mentioned that the route doesn't go away when the interface goes
down (which might or might not be a bug)
2) if both gateways are in the same subnet, chances are you're screwed up
anyway, because the kernel will only do ARP on one of your interface,
for both routes. I'd be interested to know if this is not the case.
What is your use-case? You are possibly applying the wrong solution to a
problem that can be solved in a cleaner way (VRRP? bonding? multipath
forwarding?) It depends on what problem you are really trying to solve.
> 2016-07-04 12:16 GMT+02:00 Wang Linetkux <chinawrj at gmail.com>:
> > Hi,
> > I think you can setup two default route with different/proper metric
> > value. Which means you use one of them as the backup line, and the
> > other as the main line.
> >
> >
> >
> > Thanks,
> > Rujun
> >
> > 2016-07-04 16:14 GMT+08:00 Baptiste Clenet <bapclenet at gmail.com>:
> >> Hi,
> >>
> >> On my board, I've got a wifi and an ethernet interfaces on the same
> >> subnet (192.168.0.0/24). Problem is if ethernet cable is unplugged I
> >> can't use wifi anymore, see
> >>
> >> root at eisox:/# ip route
> >> default via 192.168.0.50 dev eth0 proto static
> >> 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.85
> >> 192.168.0.0/24 dev apcli0 proto kernel scope link src 192.168.0.80
> >> Here, ethernet is unplugged and wifi connected to other router so I
> >> can't use the wifi (ping failed in both direction).
> >>
> >> If I delete eth route, it works.
> >> root at eisox:/# ip route del 192.168.0.0/24 dev eth0
> >> root at eisox:/# ip route
> >> default via 192.168.0.50 dev eth0 proto static
> >> 192.168.0.0/24 dev apcli0 proto kernel scope link src 192.168.0.80
> >> root at eisox:/#
> >>
> >> How can I can solve the problem?
> >> I won't know the status of Wifi and Ethernet so I would like that both
> >> can work if they are plugged.
> >>
> >> Or how to disable one interface is the other one is connected (like if
> >> ethernet is plugged, allow only ethernet to work, if it is unplugged,
> >> allow only wifi)
> >>
> >> Cheers,
> >>
> >> --
> >> Baptiste
> >>
> >> _______________________________________________
> >> Lede-dev mailing list
> >> Lede-dev at lists.infradead.org
> >> http://lists.infradead.org/mailman/listinfo/lede-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20160704/455b074e/attachment.sig>
More information about the Lede-dev
mailing list