3 # The following is to automatically configure the DHCP settings
4 # based on nvram settings. Feel free to replace all this crap
5 # with a simple "dnsmasq" and manage everything via the
6 # /etc/dnsmasq.conf config file
8 # DHCP interface (lan, wan, wifi -- any ifup *)
10 ifname
=$
(nvram get
${iface}_ifname
)
12 udhcpc
-n -q -R -s /bin
/true
-i $ifname >&- ||
{
13 # no existing DHCP server?
16 ipaddr
=$
(nvram get
${iface}_ipaddr
)
17 netmask
=$
(nvram get
${iface}_netmask
)
18 start
=$
(nvram get dhcp_start
)
19 num
=$
(nvram get dhcp_num
)
21 eval $
(ipcalc
$ipaddr $netmask ${start:-100} ${num:-150})
22 lease
=$
(nvram get dhcp_lease
)
24 # and pass the args via the commandline
25 # (because trying to edit the config from here is crazy)
26 args
="-K -F $START,$END,$NETMASK,${lease:-12h}"
29 # ignore requests from wan interface
30 wanproto
=$
(nvram get wan_proto
)
31 [ -z "$wanproto" -o "$wanproto" = "none" ] || args
="${args} -I $(nvram get wan_ifname)"
34 # use dnsmasq for local dns requests
35 rm -f /tmp
/resolv.conf
36 cat > /tmp
/resolv.conf
<<EOF