Skip to content

Commit

Permalink
Bug 2024826: Allow resolv prepender without default search domain
Browse files Browse the repository at this point in the history
Commit e1fbf07 introduced a regression where the local nameserver was
only prepended to the list of nameservers when the NM generated
`resolv.conf` had a default search domain.

This commit fix the regex to look for nameservers rather than search
domain, and makes the script a little more robust by using start of
line anchor in regexes.
  • Loading branch information
mandre committed Nov 19, 2021
1 parent ab92327 commit 09fab1e
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -69,9 +69,9 @@ contents:
>&2 echo "NM resolv-prepender: Prepending 'nameserver $NAMESERVER_IP' to /etc/resolv.conf (other nameservers from /var/run/NetworkManager/resolv.conf)"
sed -e "/Generated by/c# Generated by KNI resolv prepender NM dispatcher script" \
/var/run/NetworkManager/resolv.conf > /etc/resolv.tmp
sed -i "s/search.*/\0\nnameserver $NAMESERVER_IP/" /etc/resolv.tmp
sed -i "s/^nameserver.*/nameserver $NAMESERVER_IP\n\0/" /etc/resolv.tmp
# Make sure cluster domain is first in the search list
sed -i "s/search \(.*\)/search {{.DNS.Spec.BaseDomain}} \1/" /etc/resolv.tmp
sed -i "s/^search \(.*\)/search {{.DNS.Spec.BaseDomain}} \1/" /etc/resolv.tmp
# Remove duplicate cluster domain entries
sed -i "s/\(search {{.DNS.Spec.BaseDomain}}.*\) {{.DNS.Spec.BaseDomain}}\( .*\|$\)/\1\2/" /etc/resolv.tmp
# Only leave the first 3 nameservers in /etc/resolv.conf
Expand Down

0 comments on commit 09fab1e

Please sign in to comment.