A solution for multiple routes (usb0+eth0)

Atilla Filiz atilla.filiz at gmail.com
Mon Mar 9 13:23:04 CET 2009


An elegant solution for an annoying problem. Thank you.

On Mon, Mar 9, 2009 at 10:51 AM, Helge Hafting <helge.hafting at hist.no>wrote:

> Bringing up one interface creates a default route, which is necessary no
> matter which interface is used.
>
> Bringing up both interfaces makes two default routes, and there is the
> risk that the phone ends up using the slower interface which obviously
> is a problem.
>
> I set up /etc/network/interfaces like this, adapted from SHR:
>
> auto usb0
> iface usb0 inet static
>        address 192.168.0.202
>        netmask 255.255.255.0
>        network 192.168.0.0
>        gateway 192.168.0.200 metric 1
>        up echo nameserver 208.67.222.222 >> /etc/resolv.conf
>        up echo nameserver 208.67.220.220 >> /etc/resolv.conf
>
> The "metric" does the trick. When usb0 is the only interface, the usb0
> route gets used as usual.
>
> If some other interface comes up (in my case, eth0)
> then that one gets a default route too, but that default route
> comes up with the default metric of 0.
>
> So, the eth0 default route is seen as "shorter", and is preferred over
> usb0 when both are available. Which is good, as eth0 is faster.
>
> So, no need to delete the usb0 default route when bringing up other
> interfaces, with the associated problem of restoring the usb0 route when
> the other interface goes away.
>
> Helge Hafting
>
> _______________________________________________
> Openmoko community mailing list
> community at lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community
>



-- 
---------------------------------------------------------
Atilla Filiz
Eindhoven University of Technology
Embedded Systems, Master's Programme
--------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openmoko.org/pipermail/community/attachments/20090309/73379dae/attachment.htm 


More information about the community mailing list