Some of my "tools"
viewtopic.php?t=177551#p953746
For example for 10.31.42.56/16 (no matter the ".0.0" at the end)
{
:local source 10.31.42.56/16
:local ip [:toip [:pick $source 0 [:find $source "/"]]]
:local prefix [:tonum [:pick $source ([:find $source "/"] + 1) [:len $source]]]
:local submask (255.255.255.255<<(32 - $prefix))
:local addrspace (~$submask)
:local totip ([:tonum $addrspace] + 1)
:local network ($ip & $submask)
:local broadcast ($ip | $addrspace)
:local first (($network + 1) - ($prefix / 31))
:local last (($broadcast - 1) + ($prefix / 31))
:local usable (($last - $network) + ($prefix / 31))
:put " Source: $source"
:put " IP: $ip"
:put "Subnet Prefix: $prefix"
:put " Subnet Mask: $submask"
:put "Address Space: $addrspace"
:put " Total IPs: $totip"
:put " Network* IP: $network"
:put "Broadcast* IP: $broadcast"
:put " First* IP: $first"
:put " Last* IP: $last"
:put " Usable* IPs: $usable"
}
out code
Source: 10.31.42.56/16
IP: 10.31.42.56
Subnet Prefix: 16
Subnet Mask: 255.255.0.0
Address Space: 0.0.255.255
Total IPs: 65536
Network* IP: 10.31.0.0
Broadcast* IP: 10.31.255.255
First* IP: 10.31.0.1
Last* IP: 10.31.255.254
Usable* IPs: 65534
* = Network / Broadcast / First IP and Last IP are valid only when the IP are distribuited on local LAN,
instead for routing only, all IP can be used.
.0 and .255 are perfectly valid IP if are not the network ip or the broadcast address,
but for compatibility with some end devices that have problems with .0 and .255 outside a /24, is better remove all .0 and all .255 from the IP pools assigned from DHCP Server.
And for 10.0.88.0/24
out code
Source: 10.0.88.0/24
IP: 10.0.88.0
Subnet Prefix: 24
Subnet Mask: 255.255.255.0
Address Space: 0.0.0.255
Total IPs: 256
Network* IP: 10.0.88.0
Broadcast* IP: 10.0.88.255
First* IP: 10.0.88.1
Last* IP: 10.0.88.254
Usable* IPs: 254