You are not logged in.

#1 2021-04-23 10:57:46

one_half_3544
Member
Registered: 2021-04-23
Posts: 5

dhclient overwrites resolv.conf even when resolvconf is installed

Hi!

dhclient updates /etc/resolv.conf when a new lease is obtained (this is something needed as otherwise name resolution won't work).
However, when the resolvconf is installed and there are other active 'providers' of DNS servers names (like openconnect vpnc-script), dhclient continues to mess (during every lease update) with the resolv.conf contents, overwriting it directly.

The solution is pretty easy - switch dhclient to resolvconf usage:

--- /tmp/dhclient-script_make_resolv_conf   2021-03-29 18:57:40.501698266 +0200
+++ /etc/dhclient-enter-hooks   2021-03-29 17:45:40.048533479 +0200
@@ -37,11 +39,9 @@
             sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
         fi
  
-   if [ -f /etc/resolv.conf ]; then
-       chown --reference=/etc/resolv.conf $new_resolv_conf
-       chmod --reference=/etc/resolv.conf $new_resolv_conf
-   fi
-        mv -f $new_resolv_conf /etc/resolv.conf
+   cat $new_resolv_conf | /usr/bin/resolvconf -a $interface
+   rm $new_resolv_conf
+
     # DHCPv6
     elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
         new_resolv_conf=/etc/resolv.conf.dhclient-new

and a clean-up part in /etc/dhclient-exit-hooks

case "$reason" in
    EXPIRE|FAIL|RELEASE|STOP)
	/usr/bin/resolvconf -d $interface
        ;;
esac

This works fine for me - I have both vpn and isp nameservers in the /etc/resolv.conf and they all update automatically.

Should this be fixed somewhere globally? Not sure where exactly - in dhclient repo? or in the arch package? resolvconf detection should be added, of course, to preserve the original behaviour.

Thanks.

Last edited by one_half_3544 (2021-04-23 11:05:16)

Offline

#2 2021-04-23 11:42:17

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 9,211

Re: dhclient overwrites resolv.conf even when resolvconf is installed

dhclient is part of the ISC dhcp package. ISC is switching to a new dhcp server, kea but that one doesn't have a dhcp client .

https://gitlab.isc.org/isc-projects/dhcp wrote:

ISC DHCP is an open source solution for DHCP servers, relay agents, and clients, both IPv4 and IPv6. Please note that this project is in maintenance mode - we are not actively adding new functionality and may not respond to non-critical issues.

Looks like adding resolvconf support would be simplest through a patch to the archlinux dhcp / dhclient package.

Last edited by Lone_Wolf (2021-04-23 11:43:36)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2021-04-23 12:12:56

one_half_3544
Member
Registered: 2021-04-23
Posts: 5

Re: dhclient overwrites resolv.conf even when resolvconf is installed

ok, I'll prepare a clean patch. How should it be submitted? Via a bug report in https://bugs.archlinux.org/?project=1&string=dhclient ?

Thanks.

Offline

#4 2021-04-23 12:18:45

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 8,582

Re: dhclient overwrites resolv.conf even when resolvconf is installed

Patching in features isn't something Arch does in most cases. Why not just switch to a client that supports resolvconf?

The patch also makes resolvconf a hard dep, I doubt that would be accepted anywhere.

Last edited by Scimmia (2021-04-23 12:26:52)

Offline

#5 2021-04-23 12:27:09

one_half_3544
Member
Registered: 2021-04-23
Posts: 5

Re: dhclient overwrites resolv.conf even when resolvconf is installed

Scimmia wrote:

Patching in features isn't something Arch does in most cases. Why not just switch to a client that supports resolvconf?

Not adding features is reasonable, but since both dhclient and openconnect packages come from the arch-linux repo, the fact they don't play nice together is still technically a bug, not a missing functionality, isn't it?

Having said that, which dhcp client suports resolvconf? (I just don't know. And, trying to keep things minimal, just chose the smallest version).

Scimmia wrote:

The patch also makes resolvconf a hard dep, I doubt that would be accepted anywhere.

As mentioned before, adding [ -f /usr/bin/resolvonf ] (or what would be the proper way to detect the package presence? ) is not a problem.

Last edited by one_half_3544 (2021-04-23 12:50:15)

Offline

#6 2021-04-23 14:27:02

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 8,582

Re: dhclient overwrites resolv.conf even when resolvconf is installed

one_half_3544 wrote:

Having said that, which dhcp client suports resolvconf? (I just don't know. And, trying to keep things minimal, just chose the smallest version).

Depends on exactly what you're doing with it. If you just need a standalone dhcp client, dhcpcd comes to mind.

Offline

#7 2021-04-23 15:21:36

seth
Member
Registered: 2012-09-03
Posts: 21,185

Re: dhclient overwrites resolv.conf even when resolvconf is installed

Offline

#8 2021-06-11 06:31:47

one_half_3544
Member
Registered: 2021-04-23
Posts: 5

Re: dhclient overwrites resolv.conf even when resolvconf is installed

Ok, they have declined the idea - https://gitlab.isc.org/isc-projects/dhcp/-/issues/194.

So, again, how about adding this patch to the archlinux package? (modified to detect openresolv presence and use old the behaviour if it is not there, of course).

Offline

#9 2021-06-11 13:37:01

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 9,211

Re: dhclient overwrites resolv.conf even when resolvconf is installed

I suggest you contact the archlinux dev who maintains the dhpc / dhclient package (Christian Hesse aka eworm) through mailing list, personal email, irc, matrix etc to see if he's willing to add this.

Incase he's not, I think a package with this change is eligible for AUR since it adds functionality not presesnt in the repo package.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#10 2021-06-11 13:41:01

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 8,582

Re: dhclient overwrites resolv.conf even when resolvconf is installed

one_half_3544 wrote:

Ok, they have declined the idea - https://gitlab.isc.org/isc-projects/dhcp/-/issues/194.

So, again, how about adding this patch to the archlinux package? (modified to detect openresolv presence and use old the behaviour if it is not there, of course).

Already covered in post #4. Patching in non-upstream features is pretty much a no-go.

Offline

Board footer

Powered by FluxBB