Re: Support for adding /etc/hosts entries



On Sat, 2008-08-02 at 08:52 +0100, Roy Marples wrote:
> On Sat, 2008-08-02 at 00:01 +0000, Brett Johnson wrote:
> > On Fri, 2008-08-01 at 10:13 +0200, Michal Sawicz wrote:
> > > It would be great if it would be possible to add hosts entries
> > > to /etc/hosts based on the network we're connected to.
> > 
> > I currently do this with a script in /etc/dhcp3/dhclient-exit-hooks.d/
> > It just checks for the appropriate domain name in "$new_domain_name",
> > and copies/links an appropriate /etc/hosts file based on that.
> > 
> > Not saying that a GUI to do it via NM wouldn't be nice, just that it's
> > possible now w/out it.
> 
> You should be aware that current NM svn sources will send both dhclient
> and dhcpcd a different script to run than the default, so your
> enter/exit hooks won't get called.
> 
> Also, that looks like a Debian/Ubuntu derived script as the stock
> dhclient script only allows one exit hook and one enter hook ;)
> 
> dhcpcd ships with a NM hook script which just calls the script NM would
> have run, but NM needs to be patched NOT to override the script. Maybe
> we should make this into a compile option? It could be something like
> this in practice:
> 
> dhcpcd -BKL -C mtu -C resolv.conf -C ntp.conf eth0
> 
> That tells dhcpcd not to run the hook scripts to configure MTU, DNS or
> NTP as NM likes to do so itself, but allow any other and user defined
> hook scripts to run.

The problem with allowing hooks for dhcpcd and dhclient is that the
settings that get applied are _NOT_ just DHCP-derived settings.  You may
have VPN settings, you may have overridden some DHCP-derived settings
via manual configuration, or added to DHCP-derived settings via manual
configuration, etc.  DHCP is just one source of configuration data for
your system, and thus a DHCP hook script will not have the full picture
of network settings.  Only dispatcher scripts will.

Dan



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