hvtools: Fix setting the DNS server when the host reconfigures network

Busybox ifup does not modify /etc/resolv.conf

Update the hv_set_ifconfig script to overwrite /etc/resolv.conf

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2016-03-09 17:35:00 +00:00
parent b3a82885ba
commit 5d0dfdf4fa

View File

@ -58,9 +58,6 @@
# Stash away a copy of the config we got
cp $1 /etc/network/hv_config
# This is where we write the configuration
outf=/etc/network/interfaces
# Source it
. $1
@ -68,6 +65,7 @@ outf=/etc/network/interfaces
ifdown -f $DEVICE
# create a new interfaces file
outf=/etc/network/interfaces
echo "auto lo" > $outf
echo "iface lo inet loopback" >> $outf
echo "" >> $outf
@ -80,10 +78,16 @@ else
echo " address $IPADDR0" >> $outf
echo " netmask $NETMASK0" >> $outf
echo " gateway $GATEWAY" >> $outf
echo " nameserver $DNS1 $DNS2 $DNS3" >> $outf
fi
echo " hwaddress ether $HWADDR" >> $outf
# create a new resolve.conf file
outf=/etc/resolv.conf
[ -n "$DNS1" ] && echo "nameserver $DNS1" > $outf
[ -n "$DNS2" ] && echo "nameserver $DNS2" >> $outf
[ -n "$DNS3" ] && echo "nameserver $DNS3" >> $outf
[ -n "$DNS4" ] && echo "nameserver $DNS4" >> $outf
# Up the interface
ifup $DEVICE