2 ########################################################################
3 # Begin $rc_base/init.d/dnsmasq
5 # Description : dnsmasq init script
7 # Authors : Michael Tremer - mitch@ipfire.org
13 ########################################################################
21 TRUST_ANCHOR
=".,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5"
22 TIMESTAMP_FILE
="/var/ipfire/dns/dnssec-timestamp"
24 # Pull custom configuration file
25 if [ -e "/etc/sysconfig/dnsmasq" ]; then
26 .
/etc
/sysconfig
/dnsmasq
29 function dnssec_args
() {
30 local cmdline
="--dnssec --dnssec-timestamp ${TIMESTAMP_FILE}"
32 if [ -n "${TRUST_ANCHOR}" ]; then
33 cmdline
="${cmdline} --trust-anchor=${TRUST_ANCHOR}"
39 function dns_forward_args
() {
42 # Do nothing if file is empty.
43 [ -s "${file}" ] ||
return
47 local enabled zone server remark
48 while IFS
="," read -r enabled zone server remark
; do
49 # Line must be enabled.
50 [ "${enabled}" = "on" ] ||
continue
52 cmdline
="${cmdline} --server=/${zone}/${server}"
58 function dns_leases_args
() {
59 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dhcp
/settings
)
61 # If the DHCP server is enabled and DNS Update (RFC2136) is
62 # enabled, too, we won't overlay the internal domain with
63 # the dynamic/static leases.
65 if ([ "${ENABLE_GREEN}" = "on" ] ||
[ "${ENABLE_BLUE}" = "on" ]) \
66 && [ "${DNS_UPDATE_ENABLED}" = "on" ]; then
70 echo "-l /var/state/dhcp/dhcpd.leases"
75 # kill already running copy of dnsmasq...
76 killproc
/usr
/sbin
/dnsmasq
2>&1 > /dev
/null
78 boot_mesg
"Starting Domain Name Service Proxy..."
80 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
82 [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS
="$ARGS -s $DOMAIN_NAME_GREEN"
85 ARGS
="${ARGS} $(dns_leases_args)"
87 echo > /var
/ipfire
/red
/resolv.conf
# Clear it
88 if [ -e "/var/ipfire/red/dns1" ]; then
89 DNS1
=$
(cat /var
/ipfire
/red
/dns1
2>/dev
/null
)
90 if [ ! -z ${DNS1} ]; then
91 echo "nameserver ${DNS1}" >> /var
/ipfire
/red
/resolv.conf
94 if [ -e "/var/ipfire/red/dns2" ]; then
95 DNS2
=$
(cat /var
/ipfire
/red
/dns2
2>/dev
/null
)
96 if [ ! -z ${DNS2} ]; then
97 echo "nameserver ${DNS2}" >> /var
/ipfire
/red
/resolv.conf
100 [ -e "/var/ipfire/red/active" ] && ARGS
="$ARGS -r /var/ipfire/red/resolv.conf"
102 ARGS
="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`"
104 # Add custom forward dns zones.
105 ARGS
="${ARGS} $(dns_forward_args /var/ipfire/dnsforward/config)"
107 # Enabled DNSSEC validation
108 if [ "${ENABLE_DNSSEC}" -eq 1 ]; then
109 ARGS
="${ARGS} $(dnssec_args)"
112 if [ -n "${CACHE_SIZE}" ]; then
113 ARGS
="${ARGS} --cache-size=${CACHE_SIZE}"
116 loadproc
/usr
/sbin
/dnsmasq
${ARGS}
118 if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
119 boot_mesg
"Using DNS server(s): ${DNS1} ${DNS2}"
125 boot_mesg
"Stopping Domain Name Service Proxy..."
126 killproc
/usr
/sbin
/dnsmasq
136 statusproc
/usr
/sbin
/dnsmasq
140 echo "Usage: ${0} {start|stop|restart|status}"
145 # End $rc_base/init.d/dnsmasq