How to get host min host max from cidr ?

How to in ROS get host min & host max from cidr?
For example for 192.168.0.0/24 host min 192.168.0.1, host max 192.168.0.254

On Winbox, mouse-over the IP Address set (at IP > Addresses).

A popup will show you the whole range; bear in mind lowest IP will be network address, while max IP will be the broadcast one.

The rest (network address +1 up to broadcast address -1) will be the host min and host max IP respectively.

You may also use ipcalc either online or installing it on your desktop, or use Mikrotik Subnet Helper as reference.

Presumably he was asking about how to do it in a script, not in Winbox, as this is the Scripting section of the forum…

Something like this should get you started. Obviously it could do with error checking and validation etc.:

:global ipcidr "192.168.3.100/27"
:global pos [:find $ipcidr "/"]
:global ip1 [:pick $ipcidr 0 $pos]
:global cidr1 [:pick $ipcidr ($pos+1) ($pos+3)]
:global mask1 (255.255.255.255 << (32-$cidr1))
:put $ipcidr
:put $ip1
:put $cidr1
:put $mask1
:put (($ip1 & $mask1)+1)
:put (($ip1 | ~$mask1)-1)

sid5632, thank you

Ooops… my fault :slight_smile: