diff options
author | David Kaspar [Dee'Kej] <dkaspar@redhat.com> | 2017-10-30 17:08:42 +0100 |
---|---|---|
committer | Dee'Kej <deekej@linuxmail.org> | 2017-11-02 11:54:44 +0100 |
commit | 4da9dbaffba4af74eb632d1a5d10e5c366475516 (patch) | |
tree | d2d5add20fe28b262e0640daf595534b3b0edc1a /sysconfig/network-scripts/ifdown-post | |
parent | 995e8ad74f5a6bc51f28c0be4ed02c547e0891d6 (diff) | |
download | initscripts-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/ifdown-post')
-rwxr-xr-x | sysconfig/network-scripts/ifdown-post | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post index 426dae3e..229c9877 100755 --- a/sysconfig/network-scripts/ifdown-post +++ b/sysconfig/network-scripts/ifdown-post @@ -18,35 +18,39 @@ source_config /etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE} ${DEVNAME} -if [ "$PEERDNS" != "no" -o -n "$RESOLV_MODS" -a "$RESOLV_MODS" != "no" ] && \ +# Remove duplicate DNS entries and shift them, +# to have always correct condition below... +update_DNS_entries + +if ! is_false "${PEERDNS}" || ! is_false "${RESOLV_MODS}" && \ [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" -o -n "${DNS1}" \ -o "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ] ; then -if [ -f /etc/resolv.conf.save ]; then - change_resolv_conf /etc/resolv.conf.save - rm -f /etc/resolv.conf.save -fi -if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then - if [ -f /etc/ppp/peers/$DEVICE ] ; then - rm -f /etc/ppp/peers/$DEVICE + if [ -f /etc/resolv.conf.save ]; then + change_resolv_conf /etc/resolv.conf.save + rm -f /etc/resolv.conf.save + fi + if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then + if [ -f /etc/ppp/peers/$DEVICE ] ; then + rm -f /etc/ppp/peers/$DEVICE + fi fi -fi fi # Reset the default route if this interface had a special one if ! check_default_route ; then # ISDN device needs special handling dial on demand if [ "${DEVICETYPE}" = "ippp" -o "${DEVICETYPE}" = "isdn" ] && \ - [ "$DIALMODE" = "auto" ] ; then - if [ -z "$GATEWAY" ] ; then - /sbin/ip route add default ${METRIC:+metric} \ - ${WINDOW:+window $WINDOW} dev ${DEVICE} + [ "$DIALMODE" = "auto" ] ; then + if [ -z "$GATEWAY" ] ; then + /sbin/ip route add default ${METRIC:+metric} \ + ${WINDOW:+window $WINDOW} dev ${DEVICE} + else + /sbin/ip route add default ${METRIC:+metric} \ + ${WINDOW:+window $WINDOW} via ${GATEWAY} + fi else - /sbin/ip route add default ${METRIC:+metric} \ - ${WINDOW:+window $WINDOW} via ${GATEWAY} + add_default_route ${DEVICE} fi -else - add_default_route ${DEVICE} -fi fi # Reset firewall ZONE to "default": |