@@ -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
451469setup_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
0 commit comments