[OpenWrt-Devel] [PATCH] [dnsmasq] support enforced start-IP, end-IP, netmask

John Crispin blogic at openwrt.org
Tue Oct 14 06:25:59 EDT 2014


On 09/10/2014 17:07, Bastian Bittorf wrote:
> [dnsmasq] support enforced start-IP, end-IP, netmask
>
> there are corner cases where the "simple" setup via start/end/limit
> option does not fit, in our case we need to hand out
>
> 192.168.2.1 ... 192.168.2.254 with a netmask of /24 but
> the underlying interface has 192.168.0.1/16 so the smart
> autodetection method of the init-script does not work.
>
> our section looks like:
>
> config dhcp 'roaming'
>         option interface 'voyager'
>         option force_netmask 255.255.255.0
>         option force_startaddr 192.168.2.1
>         option force_endaddr 192.168.2.254
>
> we use the setup for having an decentralized roaming
> mechanism for an OLSR-mesh-network.
Hi,

this feature already exists. use the netmask option inside the dhcp section

    John


> Signed-off-by: Bastian Bittorf <bittorf at bluebottle.com>
> ---
>  package/network/services/dnsmasq/files/dnsmasq.init |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
> index 942acd7..3c0399b 100644
> --- a/package/network/services/dnsmasq/files/dnsmasq.init
> +++ b/package/network/services/dnsmasq/files/dnsmasq.init
> @@ -406,6 +406,9 @@ dhcp_add() {
>  	config_get leasetime "$cfg" leasetime
>  	config_get options "$cfg" options
>  	config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
> +	config_get force_netmask "$cfg" force_netmask
> +	config_get force_startaddr "$cfg" force_startaddr
> +	config_get force_endaddr "$cfg" force_endaddr
>  
>  	leasetime="${leasetime:-12h}"
>  	start="$(dhcp_calc "${start:-100}")"
> @@ -413,7 +416,7 @@ dhcp_add() {
>  	[ "$limit" -gt 0 ] && limit=$((limit-1))
>  	eval "$(ipcalc.sh "${subnet%%/*}" $netmask $start $limit)"
>  	if [ "$dynamicdhcp" = "0" ]; then END="static"; fi
> -	xappend "--dhcp-range=$networkid,$START,$END,$NETMASK,$leasetime${options:+ $options}"
> +	xappend "--dhcp-range=$networkid,${force_startaddr:-$START},${force_endaddr:-$END},${force_netmask:-$NETMASK},$leasetime${options:+ $options}"
>  
>  	dhcp_option_add "$cfg" "$networkid"
>  }
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list