# 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
# 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
$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