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

Re: Stop dhclient from adding a default gateway



David A. Parker wrote:
> >The dhclient-script sets the route.  If you want to prevent it then
> >you will have to either prevent dhclient-script from setting it or to
> >remove it after it has been set.
> 
> Thanks, Bob.  I had looked at dhclient-script and realized that it
> was the culprit, but I was hoping to avoid hacking up that script.

Not hacking on that script was why I proposed adding

  /etc/dhcp3/dhclient-enter-hooks.d/no-default-route

instead.  That way the original script isn't changed.  But it is
controlling that script from the outside.  By adding that script which
gets sourced by the other.

If your /etc/network/interfaces uses static addresses doesn't have a
gateway and it is a static route then it shouldn't be added.  If your
/etc/network/interfaces uses dhcp addresses then one pretty much
unconditionally gets added by the dhclient-script unless you take
steps to prevent it.

Or you could remove them after the fact as you have been trying to do.

> route del -net 10.5.2.0/24 gw 0.0.0.0 dev vlan52
> 
> But this removes the static route instead!  I don't know why it's
> behaving like that.
> ...
> I'm very confused by this.  Does the kernel absolutely require a
> default route for every network the host is on?  Because that's
> exactly what I'm trying to avoid.

No.  You are not getting distracted by the subnet route perhaps?

Please show the output from 'route -n' or 'netstat -nr'.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: