Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Resolved] Have dhcpcd ignore RDNSS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
hoel
n00b
n00b


Joined: 20 Sep 2021
Posts: 4

PostPosted: Tue Mar 18, 2025 11:03 pm    Post subject: [Resolved] Have dhcpcd ignore RDNSS Reply with quote

Hi,

I’ve recently setup a local recursive dns resolver on my computer. Hence I’ve decided to disable dhcpcd’s resolvconf hook altogether and use a static /etc/resolv.conf with only ::1 and 127.0.0.1 as nameservers.

Unfortunately, it turns out some networks block UDP and/or TCP port 53 to the internet, so my newly born unbound resolver gets stuck trying to resolve anything really.

So, on some networks, which for now only consist of my local college eduroam, I need to get a list of working DNS servers from the DHCP and have that list have priority over my local dns resolver.

So, I’ve decided to add ::1 and 127.0.0.1 to /etc/resolv.conf.tail, and ask dhcpcd not to setup DNS, by not asking, and removing if it was sent, the domain_name_servers DHCP option, unless the current interface ssid happens to be eduroam.

It works perfectly well: at home I get no DNS, at work I have the faculty DNS.

And then comes IPv6.

Turns out IPv6 setups DNS not by asking for it in a DHCP option (maybe it can also be done this way through DHCPv6, but that’s not what I have at home), but by using the RDNSS message sent in a Router Advertisement sent in response to a Router Sollicitation. I couldn’t find out how to tell dhcpcd not to use the content of the RDNSS message, and I need to get a Router Advertisement to have any ipv6 at all (meaning an ipv6 not-local link address and an ipv6 route to the Internet).

So, how can I tell dhcpcd to ignore RDNSS messages while still processing the rest of a Router Advertisement?


Last edited by hoel on Wed Mar 19, 2025 5:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
user
Apprentice
Apprentice


Joined: 08 Feb 2004
Posts: 233

PostPosted: Wed Mar 19, 2025 3:21 pm    Post subject: Reply with quote

Hi,
ignoring RDNSS info from RA is possible by disabling builtin dhcpcd resolv.conf hook (skip_hooks=resolv.conf) and using custom dhcpcd exit-hook.d script.

Another way to go is first to accept RA und DHCPv6 (client INFORM6 request) answers (including dhcpcd local host modification) and afterwards run a custom dhcpcd exit-hook.d script to "fixup" local host resolv.conf.

Hence, there is no simple dhcpcd config option.
Back to top
View user's profile Send private message
hoel
n00b
n00b


Joined: 20 Sep 2021
Posts: 4

PostPosted: Wed Mar 19, 2025 5:07 pm    Post subject: Reply with quote

Hi,

Very good catch, I totally missed that the 20-resolv.conf hook was responsible for setting up resolv.conf from RDNSS (I could have guessed, given the name, and the fact that I had indeed no DNS setup when I blacklisted it ^^’).

I found then the offending lines in it and applied the following patch:

Code:

diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf
index 7c29e276..e55b535e 100644
--- a/hooks/20-resolv.conf
+++ b/hooks/20-resolv.conf
@@ -120,9 +120,9 @@ add_resolv_conf()
       i=$(($i + 1))
       j=1
    done
-   [ -n "$new_rdnss" ] && \
+   [ -n "$new_rdnss" ] && [ "$skip_rdnss" != YES ] && \
       new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$new_rdnss"
-   [ -n "$new_dnssl" ] && \
+   [ -n "$new_dnssl" ] && [ "$skip_dnssl" != YES ] && \
       new_domain_search="$new_domain_search${new_domain_search:+ }$new_dnssl"
 
    # Derive a new domain from our various hostname options


You can save it in /etc/portage/patches/net-misc/dhcpcd/skip-rdnss.patch for it to be automatically applied on dhcpcd updates.

Then, I can toggle RDNSS on and off in my configuration file with
Code:
env skip_rdnss=YES
or
Code:
env skip_rdnss=NO
.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum