[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DHCP and IP routing

On Sat, Jan 22, 2005 at 09:49:11PM +0100, Urs Thuermann wrote:
> This causes another router to be used for the default route.  However,
> I don't want any default route on that interface.  I would like to add
> a subnet route using the router from the DHCP reply.  But I have not
> found any option to set a subnet route nor any way (say a variable) to
> refer to some specific value from the DHCP reply.  I couldn't even
> configure dhclient to not set any default route.  By giving an
> unreachable router like
>     supersede routers;
> I could achieve it in a somewhat unclean way with an error message.  I
> then added in /etc/network/interfaces an entry like
>    iface eth0 inet dhcp
>        up ip route add via
> what does what I need, but I'd prefer not to have to specify the
> router statically in that file but use the router from the DHCP
> reply.  I the router address changes some day, the statically
> configured router will cause problems and I need to adapt instead of
> having this be done automatically.

OK, so if I understand correctly, you want eth0 to use the DHCP-
supplied router only for the network and not as a default
gateway, right?  If that's the case, try this in

iface eth0 inet dhcp
  up route add -net gw `route -n | grep ^ | cut -c 17-32`
  up route del default gw `route -n | grep ^ | cut -c 17-32`

Try out the `route -n | grep ^ | cut -c 17-32` on the command
line first to ensure that it returns the correct IP address; you may
need to grep for, e.g., ^*eth0$ instead if you have two
default routes specified at that point in your startup sequence.

The freedoms that we enjoy presently are the most important victories of the
White Hats over the past several millennia, and it is vitally important that
we don't give them up now, only because we are frightened.
  - Eolake Stobblehouse (http://stobblehouse.com/text/battle.html)

Reply to: