]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/dnsmasq
dnsmasq: Disable parsing leases when DNS Update is enabled
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / dnsmasq
CommitLineData
d1e90efc
MT
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/dnsmasq
4#
5# Description : dnsmasq init script
6#
7# Authors : Michael Tremer - mitch@ipfire.org
8#
9# Version : 01.00
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
16a61778
MT
18# Pull custom configuration file
19if [ -e "/etc/sysconfig/dnsmasq" ]; then
20 . /etc/sysconfig/dnsmasq
21fi
22
45e65f1d
MT
23CACHE_SIZE=2500
24ENABLE_DNSSEC=1
f480386f 25SHOW_SRV=1
45e65f1d
MT
26TRUST_ANCHOR=".,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5"
27
28function dnssec_args() {
de7abd2c 29 local cmdline="--dnssec --dnssec-timestamp"
45e65f1d
MT
30
31 if [ -n "${TRUST_ANCHOR}" ]; then
32 cmdline="${cmdline} --trust-anchor=${TRUST_ANCHOR}"
33 fi
34
35 echo "${cmdline}"
36}
f480386f 37
e4ba53ed
SS
38function dns_forward_args() {
39 local file="${1}"
40
41 # Do nothing if file is empty.
42 [ -s "${file}" ] || return
43
44 local cmdline
45
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
50
51 cmdline="${cmdline} --server=/${zone}/${server}"
52 done < ${file}
53
54 echo "${cmdline}"
55}
56
28fee676
MT
57function dns_leases_args() {
58 eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings)
59
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.
63
64 if ([ "${ENABLE_GREEN}" = "on" ] || [ "${ENABLE_BLUE}" = "on" ]) \
65 && [ "${DNS_UPDATE_ENABLED}" = "on" ]; then
66 return
67 fi
68
69 echo "-l /var/state/dhcp/dhcpd.leases"
70}
71
d1e90efc
MT
72case "${1}" in
73 start)
fcfd54ba
AF
74 # kill already running copy of dnsmasq...
75 killproc /usr/sbin/dnsmasq 2>&1 > /dev/null
76
d1e90efc
MT
77 boot_mesg "Starting Domain Name Service Proxy..."
78
79 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
2340d265 80 ARGS="$CUSTOM_ARGS"
2b1ff411 81 [ "$DOMAIN_NAME_GREEN" != "" ] && ARGS="$ARGS -s $DOMAIN_NAME_GREEN"
28fee676
MT
82
83 # DHCP configuration
84 ARGS="${ARGS} $(dns_leases_args)"
85
f480386f
MT
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)
2789f357
AF
89 if [ ! -z ${DNS1} ]; then
90 echo "nameserver ${DNS1}" >> /var/ipfire/red/resolv.conf
91 fi
f480386f
MT
92 fi
93 if [ -e "/var/ipfire/red/dns2" ]; then
94 DNS2=$(cat /var/ipfire/red/dns2 2>/dev/null)
2789f357
AF
95 if [ ! -z ${DNS2} ]; then
96 echo "nameserver ${DNS2}" >> /var/ipfire/red/resolv.conf
97 fi
f480386f
MT
98 fi
99 [ -e "/var/ipfire/red/active" ] && ARGS="$ARGS -r /var/ipfire/red/resolv.conf"
e4ba53ed 100
63aceb22 101 ARGS="$ARGS --domain=`cat /var/ipfire/main/settings |grep DOMAIN |cut -d = -f 2`"
e4ba53ed
SS
102
103 # Add custom forward dns zones.
104 ARGS="${ARGS} $(dns_forward_args /var/ipfire/dnsforward/config)"
105
45e65f1d
MT
106 # Enabled DNSSEC validation
107 if [ "${ENABLE_DNSSEC}" -eq 1 ]; then
108 ARGS="${ARGS} $(dnssec_args)"
109 fi
110
111 if [ -n "${CACHE_SIZE}" ]; then
112 ARGS="${ARGS} --cache-size=${CACHE_SIZE}"
113 fi
114
28fee676 115 loadproc /usr/sbin/dnsmasq ${ARGS}
f480386f
MT
116
117 if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
118 boot_mesg "Using DNS server(s): ${DNS1} ${DNS2}"
119 boot_mesg_flush
120 fi
d1e90efc
MT
121 ;;
122
123 stop)
124 boot_mesg "Stopping Domain Name Service Proxy..."
125 killproc /usr/sbin/dnsmasq
126 ;;
127
128 restart)
129 ${0} stop
130 sleep 1
131 ${0} start
132 ;;
133
134 status)
135 statusproc /usr/sbin/dnsmasq
136 ;;
137
138 *)
139 echo "Usage: ${0} {start|stop|restart|status}"
140 exit 1
141 ;;
142esac
143
144# End $rc_base/init.d/dnsmasq