resolv.conf parsing optimizations
This commit is contained in:
parent
42bee2ae2f
commit
03cf6ddf2e
1 changed files with 2 additions and 2 deletions
|
@ -110,13 +110,13 @@ new_client_dns () {
|
|||
1|"")
|
||||
# Locate the proper resolv.conf
|
||||
# Needed for systems running systemd-resolved
|
||||
if grep -q "127.0.0.53" "/etc/resolv.conf"; then
|
||||
if grep -q '^nameserver 127.0.0.53' "/etc/resolv.conf"; then
|
||||
resolv_conf="/run/systemd/resolve/resolv.conf"
|
||||
else
|
||||
resolv_conf="/etc/resolv.conf"
|
||||
fi
|
||||
# Extract nameservers and provide them in the required format
|
||||
dns=$(grep -v '#' "$resolv_conf" | grep nameserver | grep -E -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
|
||||
dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
|
||||
;;
|
||||
2)
|
||||
dns="8.8.8.8, 8.8.4.4"
|
||||
|
|
Loading…
Add table
Reference in a new issue