Given a network definition like 192.168.1.0/24, I'd like to convert the /24 CIDR to a four digit netmask, in this case 255.255.255.0.
No extra gems should be used.
Given a network definition like 192.168.1.0/24, I'd like to convert the /24 CIDR to a four digit netmask, in this case 255.255.255.0.
No extra gems should be used.
Copyright © 2021 Jogjafile Inc.
Ruby's
IPAddrdoes not appear to expose this functionality. However, it contains a private instance variable called@mask_addrthat contains the integer value of the desired mask.It can be represented as a four digit submask by converting it back to another
IPAddrinstance: