X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/c05762dd883ddbce21c7fc51a5d57b96c4a61553..cccec9f4b412fdbd076e384bb1eb89e5edcee6f5:/package/dnsmasq/files/dnsmasq.init diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init index 70488a569..47c4c2d2e 100644 --- a/package/dnsmasq/files/dnsmasq.init +++ b/package/dnsmasq/files/dnsmasq.init @@ -90,6 +90,9 @@ dnsmasq() { config_get DOMAIN "$cfg" domain + config_get_bool readethers "$cfg" readethers + [ "$readethers" = "1" ] && [ -e "/etc/ethers" ] || touch /etc/ethers + config_get leasefile $cfg leasefile [ -e "$leasefile" ] || touch "$leasefile" config_get_bool cachelocal "$cfg" cachelocal 1 @@ -176,13 +179,15 @@ dhcp_host_add() { config_get networkid "$cfg" networkid [ -n "$networkid" ] && dhcp_option_add "$cfg" "$networkid" - config_get mac "$cfg" mac - [ -n "$mac" ] || return 0 - config_get ip "$cfg" ip [ -n "$ip" ] || return 0 - append args "--dhcp-host=$mac,${networkid:+net:$networkid,}$ip${name:+,$name}" + macs="" + config_get mac "$cfg" mac + for m in $mac; do append macs "$m" ","; done + [ -n "$macs" ] || return 0 + + append args "--dhcp-host=$macs,${networkid:+net:$networkid,}$ip${name:+,$name}" } dhcp_mac_add() { @@ -235,7 +240,7 @@ dhcp_add() { DNS_SERVERS="$DNS_SERVERS $dnsserver" } - append_bool "$cfg" ignore "-2 $ifname" && return 0 + append_bool "$cfg" ignore "-2 '$ifname'" && return 0 config_get proto "$net" proto [ static = "$proto" ] || return 0 @@ -258,7 +263,7 @@ dhcp_add() { leasetime="${leasetime:-12h}" start="$(dhcp_calc "${start:-100}")" - limit="$((${limit:-150} + 1))" + limit="${limit:-150}" eval "$(ipcalc.sh $ipaddr $netmask $start $limit)" if [ "$dynamicdhcp" = "0" ]; then END="static"; fi append args "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}" @@ -279,16 +284,22 @@ dhcp_option_add() { dhcp_domain_add() { local cfg="$1" + local ip name names - config_get name "$cfg" name - [ -n "$name" ] || return 0 + config_get names "$cfg" name + [ -n "$names" ] || return 0 config_get ip "$cfg" ip [ -n "$ip" ] || return 0 local oIFS="$IFS"; IFS="."; set -- $ip; IFS="$oIFS" - append args "-A /$name${DOMAIN:+.$DOMAIN}/$ip" - append args "--ptr-record=$4.$3.$2.$1.in-addr.arpa,$name${DOMAIN:+.$DOMAIN}" + local raddr="${4:+$4.$3.$2.$1.in-addr.arpa}" + + for name in $names; do + append args "-A /$name/$ip" + [ -n "$raddr" ] && \ + append args "--ptr-record=$raddr,$name" + done } start() { @@ -311,11 +322,11 @@ start() { /usr/sbin/dnsmasq $args && { rm -f /tmp/resolv.conf + [ -n "$DOMAIN" ] && echo "search $DOMAIN" >> /tmp/resolv.conf DNS_SERVERS="$DNS_SERVERS 127.0.0.1" for DNS_SERVER in $DNS_SERVERS ; do echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf done - echo "search $DOMAIN" >> /tmp/resolv.conf } }