how to keep udhcpc from setting the default route?

Alexander Griesser alexander.griesser at lkh-vil.or.at
Wed Feb 18 13:28:45 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert P. J. Day wrote:
>   long story short:  how to not have udhcpc add default entries to the
> routing table.  obviously, i can manually remove those entries later,
> but i checked the doc for "udhcpc" and i don't see an obvious option
> that says, "don't set a default route."
> 
>   do i just do that manually after invoking "udhcpc"?  or can i tuck
> that away in the udhcpc "script" file that is run at DHCP events?
> thanks.

I would do that in the udhcpc.sh script. Depending on your
configuration, this script might look like this:

- --------------------- 8< ------------------
[...]
case $1 in
  "bound" | "renew")
        ifconfig $interface $ip netmask $subnet up
        if [ "$router" != "" ]; then
          route add default gw $router
        fi
[...]
- --------------------- 8< ------------------

As you can see, if a router option is given, it tries to set the default
route to this option.
If you can say that in your specific case, eth0 is the primary address
and eth1 is the secondary, you can modify the `route add ...` line to
something like this:

[ "$interface" = "eth0" ] && route add default gw $router

Or you can comment that out at all and set the default router manually
later on.
You could even want to check if there's already a default router present
and only if this is not the case, set the default route, that could be
done with code like this:

route -n | grep -q ^0.0.0.0 || route add default gw $router

ciao,
- --
Alexander Griesser (Netzwerkadministration)
E-Mail: alexander.griesser at lkh-vil.or.at | Web: http://www.lkh-vil.or.at
KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
Tel.:   +43 4242 208 3061 | Fax.:   +43 4242 208 971 2061
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmcDQ0ACgkQ66HVD6KUm1qQLgCdEcpmGbNVatnvra+WZlj1I48W
Rm0An3NxusM3jW9ZqS21Ct5jB2SaWSZ6
=s6Rg
-----END PGP SIGNATURE-----


More information about the busybox mailing list