[Dnsmasq-discuss] FYI: netcalc 2.1.1
Lonnie Abelbeck
lists at lonnie.abelbeck.com
Wed Mar 29 02:53:57 BST 2017
The netcalc project by Joachim Nilsson (@troglobit), is originally based on sipcalc, and the just released netcalc 2.1.1 has some new features dnsmasq configurations may be interested in.
https://github.com/troglobit/netcalc
For example, while a /24 network does not need fancy tools to calculate DHCP pool ranges, supporting arbitrary networks, pool ranges can get quite complicated.
host="192.168.101.1"
mask="255.255.255.0"
0 < $range_min < $range_max <= $max_hosts
range_min=100
range_max=200
max_hosts="$(netcalc "$host" "$mask" | sed -n -r -e 's/^Hosts\/Net *: *([0-9]+).*$/\1/p')"
# 254
ip_min="$(netcalc -R "$range_min:$range_max" "$host" "$mask" | sed -n -r -e 's/^RangeMin *: *([0-9.]+).*$/\1/p')"
# 192.168.101.100
ip_max="$(netcalc -R "$range_min:$range_max" "$host" "$mask" | sed -n -r -e 's/^RangeMax *: *([0-9.]+).*$/\1/p')"
# 192.168.101.200
dhcp-range= ... <start-addr|$ip_max>,<end-addr|$ip_max>
So, for those of you that need to configure dnsmasq with arbitrary networks, the latest netcalc 2.1.1 may be a useful tool to take a look at.
# netcalc -R 100:400 10.10.10.1/23
--
Address : 10.10.10.1 00001010.00001010.0000101 0.00000001
Netmask : 255.255.254.0 = 23 11111111.11111111.1111111 0.00000000
Wildcard : 0.0.1.255 00000000.00000000.0000000 1.11111111
=>
Network : 10.0.0.0/23 00001010.00000000.0000000 0.00000000
HostMin : 10.10.10.1 00001010.00001010.0000101 0.00000001
HostMax : 10.10.11.254 00001010.00001010.0000101 1.11111110
Broadcast: 10.10.11.255 00001010.00001010.0000101 1.11111111
Hosts/Net: 510 Class A, Private network (RFC1928)
[Range 100:400]
RangeMin : 10.10.10.100
RangeMax : 10.10.11.144
--
Lonnie
More information about the Dnsmasq-discuss
mailing list