From: Urban Wallasch Date: Tue, 23 Apr 2019 14:45:44 +0000 (+0200) Subject: * Provide guest dhclient with a pristine config file. This obsoletes the X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=d58ff5fe0edd61df74e93aa3e92c5b8b80817dcb;p=netutil.git * Provide guest dhclient with a pristine config file. This obsoletes the hack to remove any remnant /etc/resolv.conf.dhclient-new.XXXX files. * Cleaned out To-Do list. --- diff --git a/nns.sh b/nns.sh index 9059cbb..31d9444 100755 --- a/nns.sh +++ b/nns.sh @@ -5,18 +5,6 @@ # the host (default) network namespace. # -###################################################################### -# To-Do: -# ------ -# -# * Find a nice way to keep dhclient when run within a network namespace -# from littering the system with /etc/resolv.conf.dhclient-new.XXXX -# files while attempting to overwrite /etc/resolv.conf. -# Current workaround is to indiscriminately remove such files. -# Cf: https://stackoverflow.com/questions/38102481/how-can-dhclient-be-made-namespace-aware ) -# -##### - ###################################################################### # Default configuration; can be overridden by passing the name # of a shell script fragment containing appropriate variable @@ -235,9 +223,9 @@ start_nns() { # up this and the lo interface: $IP link set $VETH_GUEST netns $1 if [ -z "$GUEST_ADDR" ] ; then + # Provide the guest dhclient with its own empty configuration file: + /bin/mkdir -p /etc/netns/$1/dhcp/ && /bin/touch /etc/netns/$1/dhcp/dhcp.conf $IP netns exec $1 $DHCLIENT -pf "$RUNDIR/dhclient.$VETH_GUEST.pid" -v $VETH_GUEST - # Remove dhclients useless remains: - rm /etc/resolv.conf.dhclient-new.* else $IP netns exec $1 $IP addr add $GUEST_ADDR/$GUEST_PLEN broadcast $GUEST_BCAST dev $VETH_GUEST $IP netns exec $1 $IP link set dev $VETH_GUEST up @@ -291,7 +279,9 @@ stop_nns() { $IP link del $VETH_HOST 2> /dev/null $IP netns del $1 - # Cleanup namespace DNS configuration: + # Cleanup namespace DHCP and DNS configuration: + /bin/rm /etc/netns/$1/dhcp/dhcp.conf + /bin/rmdir /etc/netns/$1/dhcp/ /bin/rm /etc/netns/$1/resolv.conf /bin/rmdir /etc/netns/$1