6 # The following is to automatically configure the DHCP settings
7 # based on config settings. Feel free to replace all this crap
8 # with a simple "dnsmasq" and manage everything via the
9 # /etc/dnsmasq.conf config file
11 [ -f /etc
/dnsmasq.conf
] ||
exit
15 config_get ifname
"$iface" ifname
16 config_get proto
"$iface" proto
18 [ "$proto" = static
] && dhcp_enable
="${dhcp_enable:-1}"
19 dhcp_start
="${dhcp_start:-100}"
20 dhcp_num
="${dhcp_num:-50}"
21 dhcp_lease
="${dhcp_lease:-12h}"
23 # if dhcp_enable is unset and there is a dhcp server on the network already, default to dhcp_enable=0
24 [ -z "$dhcp_enable" ] && udhcpc
-n -q -R -s /bin
/true
-i $ifname >&- && dhcp_enable
="${dhcp_enable:-0}"
26 # dhcp_enable=0 disables the dhcp server
28 [ -z "$dhcp_enable" -o "$dhcp_enable" -eq 1 ] && {
29 # no existing DHCP server?
32 config_get ipaddr
"$iface" ipaddr
33 config_get netmask
"$iface" netmask
34 eval $
(ipcalc
$ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150})
36 # and pass the args via config parser defines
37 echo "${dhcp_enable:+@define dhcp_enable 1}"
38 echo "@define netmask $NETMASK"
39 echo "@define start $START"
40 echo "@define end $END"
41 echo "@define lease ${dhcp_lease:-12h}"
44 # ignore requests from wan interface
45 config_get wan_proto wan proto
46 config_get wan_ifname wan ifname
47 [ -z "$wan_proto" -o "$wan_proto" = "none" ] ||
echo "@define wan_ifname $wan_ifname"
50 ) |
awk -f /usr
/lib
/parse-config.
awk | dnsmasq
-C /proc
/self
/fd
/0