Skip to content

Commit e936257

Browse files
committed
CLOUDSTACK-1199: add external DNS to dnsmasq configuration file
1 parent d9aa051 commit e936257

2 files changed

Lines changed: 28 additions & 45 deletions

File tree

patches/systemvm/debian/config/etc/init.d/cloud-early-config

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,30 @@ setup_dnsmasq() {
440440

441441
if [ "$RROUTER" == "1" ]
442442
then
443-
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
444-
echo "dhcp-option=option:router,$GUEST_GW" >> /etc/dnsmasq.conf
445-
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
446-
echo "dhcp-option=6,$GUEST_GW" >> /etc/dnsmasq.conf
443+
DEFAULT_GW=$GUEST_GW
444+
INTERNAL_DNS=$GUEST_GW
445+
else
446+
if [ "$TYPE" == "dhcpsrvr" ]
447+
then
448+
DEFAULT_GW=$GW
449+
else
450+
DEFAULT_GW=$ETH0_IP
451+
fi
452+
INTERNAL_DNS=$ETH0_IP
447453
fi
448-
454+
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
455+
[ $DEFAULT_GW ] && echo "dhcp-option=option:router,$DEFAULT_GW" >> /etc/dnsmasq.conf
456+
NS=$NS1
457+
[ -n "$NS2" ] && NS=$NS1,$NS2
458+
#for now set up ourself as the dns server as well
459+
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
460+
if [ "$USE_EXTERNAL_DNS" == "true" ]
461+
then
462+
[ $ETH0_IP ] && echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
463+
else
464+
[ $ETH0_IP ] && echo "dhcp-option=6,$INTERNAL_DNS,$NS" >> /etc/dnsmasq.conf
465+
fi
466+
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,[::]" >> /etc/dnsmasq.conf
449467
}
450468

451469
setup_sshd(){
@@ -606,14 +624,6 @@ setup_router() {
606624

607625
setup_dnsmasq
608626

609-
NS=$NS1
610-
[ -n "$NS2" ] && NS=$NS1,$NS2
611-
if [ "$USE_EXTERNAL_DNS" == "true" ]
612-
then
613-
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
614-
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
615-
fi
616-
617627
setup_apache2 $ETH0_IP
618628

619629
sed -i /gateway/d /etc/hosts
@@ -715,28 +725,6 @@ setup_dhcpsrvr() {
715725
setup_dnsmasq
716726
setup_apache2 $ETH0_IP
717727

718-
NS=$NS1
719-
[ -n "$NS2" ] && NS=$NS1,$NS2
720-
if [ "$DEFAULTROUTE" != "false" ]
721-
then
722-
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
723-
[ $GW ] && echo "dhcp-option=option:router,$GW" >> /etc/dnsmasq.conf
724-
#for now set up ourself as the dns server as well
725-
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
726-
if [ "$USE_EXTERNAL_DNS" == "true" ]
727-
then
728-
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
729-
else
730-
[ $ETH0_IP ] && echo "dhcp-option=6,$ETH0_IP,$NS" >> /etc/dnsmasq.conf
731-
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,[::]" >> /etc/dnsmasq.conf
732-
fi
733-
else
734-
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
735-
echo "dhcp-option=option:router" >> /etc/dnsmasq.conf
736-
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
737-
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
738-
fi
739-
740728
sed -i /gateway/d /etc/hosts
741729
[ $ETH0_IP ] && echo "$ETH0_IP $NAME" >> /etc/hosts
742730
[ $ETH0_IP6 ] && echo "$ETH0_IP6 $NAME" >> /etc/hosts

patches/systemvm/debian/config/root/edithosts.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,13 @@ then
173173

174174
tag=$(echo $ipv4 | tr '.' '_')
175175
sed -i /$tag/d $DHCP_OPTS
176-
if [ "$dflt" != "0.0.0.0" ]
177-
then
178-
logger -t cloud "$0: setting default router for $ipv4 to $dflt"
179-
echo "$tag,3,$dflt" >> $DHCP_OPTS
180-
else
181-
logger -t cloud "$0: unset default router for $ipv4"
182-
echo "$tag,3," >> $DHCP_OPTS
183-
fi
184-
if [ "$dns" != "" ]
176+
if [ "$dflt" == "0.0.0.0" ]
185177
then
178+
logger -t cloud "$0: unset default router for $ipv4"
179+
echo "$tag,3" >> $DHCP_OPTS
186180
logger -t cloud "$0: setting dns server for $ipv4 to $dns"
187-
echo "$tag,6,$dns" >> $DHCP_OPTS
181+
echo "$tag,6" >> $DHCP_OPTS
182+
echo "$tag,15" >> $DHCP_OPTS
188183
fi
189184
[ "$routes" != "" ] && echo "$tag,121,$routes" >> $DHCP_OPTS
190185
#delete entry we just put in because we need a tag

0 commit comments

Comments
 (0)