From: Roy Marples Date: Wed, 1 Apr 2020 12:22:15 +0000 (+0100) Subject: resolv.conf: Uniquify contents X-Git-Tag: v9.0.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8b295e1e3509a91d702cee6207f21c934c7b460;p=thirdparty%2Fdhcpcd.git resolv.conf: Uniquify contents We might have >1 router that broadcasts the same DNS information. While resolvconf(8) can easily take care of uniqifying the data, not all systems have this nice tool so do the job here as well. --- diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf index 422d815a..03e846fa 100644 --- a/hooks/20-resolv.conf +++ b/hooks/20-resolv.conf @@ -42,7 +42,7 @@ build_resolv_conf() # Build the nameserver list srvs=$(cd "$resolv_conf_dir"; \ key_get_value "nameserver " ${interfaces}) - for x in $(uniqify ${srvs}); do + for x in $(uniqify $srvs); do servers="${servers}nameserver $x$NL" done fi @@ -152,6 +152,7 @@ add_resolv_conf() fi fi if [ -n "$new_domain_search" ]; then + new_domain_search=$(uniqify $new_domain_search) if valid_domainname_list $new_domain_search; then conf="${conf}search $new_domain_search$NL" elif ! $warn; then @@ -159,6 +160,7 @@ add_resolv_conf() "$new_domain_search" fi fi + new_domain_name_servers=$(uniqify $new_domain_name_servers) for x in ${new_domain_name_servers}; do conf="${conf}nameserver $x$NL" done