dhcpcd icon indicating copy to clipboard operation
dhcpcd copied to clipboard

resolv.conf file isn't cleaned after dhcpcd timed out

Open Degoah opened this issue 2 years ago • 3 comments
trafficstars

I've noticed that dhcpcd does not clean the /etc/resolv.conf file when dhcpcd times out.

Here are the details to reproduce my observation:

  • I have a basic IPv6 environment running on my PI with a radvd (Router Advertisement Daemon) as IPv6 router and which sets the "O" flag in the RA message to make dhcpcd as DHCP client acquire DNS information from the DHCPv6server. Here is the used radvd-specific config file specially to reproduce my observation: radvd.conf.txt

  • I also have an isc-dhcp-server running as DHCP server on the PI and which has the option dhcp6.name-server set to a fictive, but valid, IPv6 address (e.g. abcd:abcd:abcd:abcd::42). Here is the used is-dhcp-server-specific config file specially to reproduce my observation: dhcpd6.conf.txt

  • Next, I connect a host with the PI and start dhcpcd with the following CLI options: sudo dhcpcd --ipv6only <your_network_interface_name> --timeout=10

When dhcpcd times out, I expect it to clean every configuration it applied, including removing the DNS entry in /etc/resolv.conf despite the general stuff like assigned network interface IP addresses and the default route etc. However, the entry nameserver abcd:abcd:abcd:abcd::47 remains in /etc/resolv.conf.

dhcpcd times out, if it doesn't assign an IP address in time to the network interface. It cannot assign any IP address, as the RA message (see the attached radvd-specific config file) doesn't contain any prefix, and because dhcpcd was asked to only request "Other" information from the DHCP server - although there is an IPv6 address range configured in the attached isc-dhcp-server-specific config file - because of the "O" flag being set in the RA message. As soon as dhcpcd receives the lease with the DNSS address, it updates /etc/resolv.conf with that DNS address and continues to wait to receive a valid IPv6 address. As this doesn't happen in time, dhcpcd times out and doesn't clean /etc/resolv.conf. The issue also occurs if thepersistent option in dhcpcd.conf is NOT.

Possible workarounds/fixes I've have figured out while playing a bit around, but not sure if they are stable as I cannot foresee which sides effects they could have due to the fact, that I'm very new to the code base of dhcpcd.

  1. 20_resolv.conf: I've observed this hook receives STOPPED in the env var $reason when dhcpcd times out, but the script doesn't call remove_resolv_conf(). Suggestion: Add an else-branch after the elif $if_down; then where the function remove_resolv_conf gets invoked. However, I'm unsure if this would not have any negative side effects on the overall configuration of the DNS network config.

  2. dhcpcd.c: Make the function handle_exit_timeout(void *arg) pass the reason STOP6 or RELEASE to the function script_runreason(). I've tried this and it had the effect, that /etc/resolv.conf got cleaned after dhcpcd timed out.

Actually, I'm not sure, if not to clean resolve.conf in case dhcpcd times out is a bug or a feature.

Degoah avatar Apr 27 '23 19:04 Degoah

Are there any plans to fix this?

Degoah avatar May 02 '23 08:05 Degoah

Yes, I just need the time and other things have priority at the moment.

rsmarples avatar May 02 '23 14:05 rsmarples

Hi Roy,

Contacting you regarding your current plan to fix this issue: any plans to fix it in the near future?

BR

Degoah avatar Jul 28 '23 13:07 Degoah