2 ########################################################################
3 # Begin $rc_base/init.d/dnsmasq
5 # Description : dnsmasq init script
7 # Authors : Michael Tremer - mitch@ipfire.org
13 ########################################################################
18 # Pull custom configuration file
19 if [ -e "/etc/sysconfig/dnsmasq" ]; then
20 .
/etc
/sysconfig
/dnsmasq
26 TRUST_ANCHOR
=".,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5"
28 function dnssec_args
() {
29 local cmdline
="--dnssec --dnssec-timestamp"
31 if [ -n "${TRUST_ANCHOR}" ]; then
32 cmdline
="${cmdline} --trust-anchor=${TRUST_ANCHOR}"
38 function dns_forward_args
() {
41 # Do nothing if file is empty.
42 [ -s "${file}" ] ||
return
46 local enabled zone server remark
47 while IFS
="," read -r enabled zone server remark
; do
48 # Line must be enabled.
49 [ "${enabled}" = "on" ] ||
continue
51 cmdline
="${cmdline} --server=/${zone}/${server}"
57 function dns_leases_args
() {
58 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dhcp
/settings
)
60 # If the DHCP server is enabled and DNS Update (RFC2136) is
61 # enabled, too, we won't overlay the internal domain with
62 # the dynamic/static leases.
64 if ([ "${ENABLE_GREEN}" = "on" ] ||
[ "${ENABLE_BLUE}" = "on" ]) \
65 && [ "${DNS_UPDATE_ENABLED}" = "on" ]; then
69 echo "-l /var/state/dhcp/dhcpd.leases"
74 # kill already running copy of dnsmasq...
75 killproc
/usr
/sbin
/dnsmasq
2>&1 > /dev
/null
77 boot_mesg
"Starting Domain Name Service Proxy..."
79 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
81 [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS
="$ARGS -s $DOMAIN_NAME_GREEN"
84 ARGS
="${ARGS} $(dns_leases_args)"
86 echo > /var
/ipfire
/red
/resolv.conf
# Clear it
87 if [ -e "/var/ipfire/red/dns1" ]; then
88 DNS1
=$
(cat /var
/ipfire
/red
/dns1
2>/dev
/null
)
89 if [ ! -z ${DNS1} ]; then
90 echo "nameserver ${DNS1}" >> /var
/ipfire
/red
/resolv.conf
93 if [ -e "/var/ipfire/red/dns2" ]; then
94 DNS2
=$
(cat /var
/ipfire
/red
/dns2
2>/dev
/null
)
95 if [ ! -z ${DNS2} ]; then
96 echo "nameserver ${DNS2}" >> /var
/ipfire
/red
/resolv.conf
99 [ -e "/var/ipfire/red/active" ] && ARGS
="$ARGS -r /var/ipfire/red/resolv.conf"
101 ARGS
="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`"
103 # Add custom forward dns zones.
104 ARGS
="${ARGS} $(dns_forward_args /var/ipfire/dnsforward/config)"
106 # Enabled DNSSEC validation
107 if [ "${ENABLE_DNSSEC}" -eq 1 ]; then
108 ARGS
="${ARGS} $(dnssec_args)"
111 if [ -n "${CACHE_SIZE}" ]; then
112 ARGS
="${ARGS} --cache-size=${CACHE_SIZE}"
115 loadproc
/usr
/sbin
/dnsmasq
${ARGS}
117 if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
118 boot_mesg
"Using DNS server(s): ${DNS1} ${DNS2}"
124 boot_mesg
"Stopping Domain Name Service Proxy..."
125 killproc
/usr
/sbin
/dnsmasq
135 statusproc
/usr
/sbin
/dnsmasq
139 echo "Usage: ${0} {start|stop|restart|status}"
144 # End $rc_base/init.d/dnsmasq