From e5883b5a5f326a8be45e199aaa9a8cf4b6523426 Mon Sep 17 00:00:00 2001 From: Obed N Munoz Date: Thu, 6 Dec 2018 13:23:20 -0600 Subject: [PATCH] Update search pattern for resolv.conf Add strict case for pattern searching on resolv.conf file. It make sure that `nameserver` and `search` keyword are the start of the string when looking for name servers and search domains on resolv.conf. Signed-off-by: Obed N Munoz --- startvm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/startvm b/startvm index 61085b5..953816e 100644 --- a/startvm +++ b/startvm @@ -392,8 +392,8 @@ if [[ "$ENABLE_DHCP" == 1 ]]; then iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill # Build DNS options from container /etc/resolv.conf - nameservers=($(grep nameserver /etc/resolv.conf | sed 's/nameserver //')) - searchdomains=$(grep search /etc/resolv.conf | sed 's/search //' | sed 's/ /,/g') + nameservers=($(grep ^nameserver /etc/resolv.conf | sed 's/nameserver //')) + searchdomains=$(grep ^search /etc/resolv.conf | sed 's/search //' | sed 's/ /,/g') domainname=$(echo $searchdomains | awk -F"," '{print $1}') for nameserver in "${nameservers[@]}"; do