dhcpcd-discuss

Re: dhcpcd --exit does not clean up resolv.conf

Henning Schild

Fri Aug 04 14:29:49 2017

> On August 4, 2017 at 11:56 AM Roy Marples <roy@xxxxxxxxxxxx> wrote:
> 
> 
> Hi
> 
> On 04/08/2017 09:08, Henning Schild wrote:
> > i am using dhcpcd and am very happy with how it manages resolv.conf
> > from various interfaces. But that magic quickly becomes a problem if
> > something like a vpn client wants to manage that file. The copy of the
> > client will get overwritten by dhcpcd all the time.
> > 
> > My solution to that is to start a dhcpcd with static ip_address routers
> > domain_name_servers domain_name ... instead of letting the vpn client
> > generate a resolv.conf. That works like a charm with i.e. the wifi
> > dhcpcd that is running next to the tun one. Local names still resolve,
> > after a while ... ;).
> > 
> > When the vpn clients shuts down i "dhcpcd -x tun" but that does not
> > clear the injected values from resolv.conf, where i think it probably
> > should. At least the nameservers seem to move down in the list.
> > I am talking about v6.11.3 in case the problem is known and fixed.
> > 
> > I think that is a good way of dealing with resolv.conf issues, or does
> > anyone have a better suggestion?
> 
> So there are two issues here:
> 1) contention for resolv.conf from seperate programs
> 2) resolv.conf isn't being cleaned up at program exit
> 
> Luckily both are easily solvable :)
> 1) Use resolvconf as a middleman - I also maintain openresolv
> https://roy.marples.name/projects/openresolv

In this scenario i can get away with just using dhcpcds and do not need a middleman.

> 2) Comment out the persistent keyword in dhcpcd.conf
> dhcpcd will then remove the lease (including IP address, routing, etc)
> from the interface when it exits.

Or  "-x -k" and keep global settings as they are.

> > Another issue i found is that "dhcpcd tun0" requires a "dhcpcd -x
> > tun0-4" to match the PIDfile. I guess the number 4 is somehow generated
> > when creating the file so the killing process should do the same steps
> > to find that file.
> 
> This is because you limited tun0 to IPv4 only either in dhcpcd.conf or
> the the commandline. As so it's expected because some users which to
> control an IPv6 instance of dhcpcd seperately.

I see "-4 -x" does the trick.

Thanks,
Henning

> Roy
>

References:
dhcpcd --exit does not clean up resolv.confHenning Schild
Re: dhcpcd --exit does not clean up resolv.confRoy Marples
Archive administrator: postmaster@marples.name