Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3998 - netifd: domain search list is written to resolv.conf incorrectly #8995

Open
openwrt-bot opened this issue Aug 31, 2021 · 1 comment
Labels
flyspray release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release

Comments

@openwrt-bot
Copy link

lutchann:

write_resolv_conf_entries() writes the DNS search domains to resolv.conf.auto one per line, whereas the musl resolver expects all domains to be listed on one line, separated by spaces.

I.e., netifd currently writes this:

# Interface lan
nameserver 192.168.100.100
search domain1.com
search domain2.com

But musl wants this:

# Interface lan
nameserver 192.168.100.100
search domain1.com domain2.com

While other resolvers are happy to append multiple "search" lines together to form the domain search list, musl overwrites its domain search list every time a new "search" line is encountered. The result is that only the lowest priority search domain specified by the network administrator is searched.

@aparcar aparcar added the release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release label Feb 22, 2022
@F-i-f
Copy link

F-i-f commented Jun 9, 2022

This can be worked around by dropping the following into /etc/hotplug.d/iface/50-fix-resolv-conf:

#!/bin/sh

RESOLVCONF=/tmp/resolv.conf.d/resolv.conf.auto

[ "$ACTION" = "ifup" -o "$ACTION" = "ifupdate" ] && {
	if [ "$(grep '^[[:space:]]*search[[:space:]]' "$RESOLVCONF" | wc -l)" -gt 1 ]
	then
		tmp="$(mktemp "$RESOLVCONF.XXXXXXX")"
		awk '{ if (/^[[:space:]]*search[[:space:]]+/) { 
		         $1 = ""; terms=terms $0;
		       } else {
		         print;
		       }
		     }
		     END {
		       if (terms != "") {
		         print "search" terms;
		       }
		     }' "$RESOLVCONF" > "$tmp"
		 chmod 644 "$tmp"
		 mv "$tmp" "$RESOLVCONF"
	fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release
Projects
None yet
Development

No branches or pull requests

3 participants