aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
authorDavid Kaspar [Dee'Kej] <dkaspar@redhat.com>2017-10-30 17:08:42 +0100
committerDee'Kej <deekej@linuxmail.org>2017-11-02 11:54:44 +0100
commit4da9dbaffba4af74eb632d1a5d10e5c366475516 (patch)
treed2d5add20fe28b262e0640daf595534b3b0edc1a /sysconfig/network-scripts/network-functions
parent995e8ad74f5a6bc51f28c0be4ed02c547e0891d6 (diff)
downloadinitscripts-4da9dbaffba4af74eb632d1a5d10e5c366475516.tar
initscripts-4da9dbaffba4af74eb632d1a5d10e5c366475516.tar.gz
initscripts-4da9dbaffba4af74eb632d1a5d10e5c366475516.tar.bz2
initscripts-4da9dbaffba4af74eb632d1a5d10e5c366475516.tar.xz
initscripts-4da9dbaffba4af74eb632d1a5d10e5c366475516.zip
ifup-post: always update nameserver & search entries in /etc/resolv.conf
This is complete rework of how we generate the /etc/resolv.conf. Fixes: * always update 'nameserver' & 'search' entries when DNS* & DOMAIN options (respectively) were updated in ifcfg-* files * always update the order of 'nameserver' entries when the order of DNS* options was updated Enhancements: * added support for DNS3 option (equals to MAXNS value in GLIBC) * added logic to process duplicate DNS* options * added logic to process randomly omitted DNS* options (e.g. omitting DNS1 while specifying DNS2 and/or DNS3 will still work now) This work was based on these two RHEL-7.5 BZs: https://bugzilla.redhat.com/show_bug.cgi?id=1364895 https://bugzilla.redhat.com/show_bug.cgi?id=1357658
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r--sysconfig/network-scripts/network-functions29
1 files changed, 29 insertions, 0 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 145ef27c..53e9d41e 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -697,3 +697,32 @@ net_log()
fi
return 0
}
+
+update_DNS_entries()
+{
+ # Remove duplicate values from DNS options if any:
+ if [ -n "${DNS3}" ] && [[ "${DNS3}" == "${DNS2}" || "${DNS3}" == "${DNS1}" ]]; then
+ unset DNS3
+ fi
+
+ if [ -n "${DNS2}" ] && [[ "${DNS2}" == "${DNS1}" ]]; then
+ unset DNS2
+ fi
+
+ # Shift the DNS options if necessary:
+ if [ -z "${DNS1}" ] && [ -n "${DNS2}" ]; then
+ DNS1="${DNS2}"
+ unset DNS2
+ fi
+
+ if [ -z "${DNS2}" ] && [ -n "${DNS3}" ]; then
+ DNS2="${DNS3}"
+ unset DNS3
+ fi
+
+ # We need to check DNS1 again in case only DNS3 was set at all:
+ if [ -z "${DNS1}" ] && [ -n "${DNS2}" ]; then
+ DNS1="${DNS2}"
+ unset DNS2
+ fi
+}