diff --git a/files/image_config/interfaces/interfaces-config.sh b/files/image_config/interfaces/interfaces-config.sh index cb2faea91f31..669d12849f10 100755 --- a/files/image_config/interfaces/interfaces-config.sh +++ b/files/image_config/interfaces/interfaces-config.sh @@ -1,4 +1,5 @@ #!/bin/bash +resolvconf_updates=true function wait_networking_service_done() { local -i _WDOG_CNT="1" @@ -23,6 +24,24 @@ function wait_networking_service_done() { systemctl kill networking 2>&1 } +function resolvconf_updates_disable() { + resolvconf --updates-are-enabled + if [[ $? -ne 0 ]]; then + resolvconf_updates=false + fi + resolvconf --disable-updates +} + +function resolvconf_updates_restore() { + if [[ $resolvconf_updates == true ]]; then + resolvconf --enable-updates + fi +} + +# Do not run DNS configuration update during the shutdowning of the management interface. +# This operation is redundant as there will be an update after the start of the interface. +resolvconf_updates_disable + if [[ $(ifquery --running eth0) ]]; then wait_networking_service_done ifdown --force eth0 @@ -61,6 +80,8 @@ for intf_pid in $(ls -1 /var/run/dhclient*.Ethernet*.pid 2> /dev/null); do done /usr/bin/resolv-config.sh cleanup +# Restore DNS configuration update to the previous state. +resolvconf_updates_restore # Read sysctl conf files again sysctl -p /etc/sysctl.d/90-dhcp6-systcl.conf diff --git a/files/image_config/resolv-config/update-containers b/files/image_config/resolv-config/update-containers index 47d8328a80fe..891fd2ea7462 100755 --- a/files/image_config/resolv-config/update-containers +++ b/files/image_config/resolv-config/update-containers @@ -1,6 +1,11 @@ #!/bin/bash -for container in $(docker ps -a --format=" {{ .ID }}"); do +networking_status=$(systemctl is-active networking.service 2>/dev/null) +if [[ $networking_status != "active" ]]; then + exit 0 +fi + +for container in $(docker ps -q); do docker cp -L /etc/resolv.conf ${container}:/_resolv.conf docker exec -t ${container} bash -c "cat /_resolv.conf > /etc/resolv.conf" docker exec -t ${container} bash -c "rm /_resolv.conf"