Our Datacenter has given us a JSON dump from all of our machines to import into our own inventory management system. This supplies the IP Blocks such as (192.168.1.1/26) but as I am importing hundreds of blocks, I would like to also calculate the Netmask and Gateway.
I looked over the networking functions on the PHP Doxygen but was not able to find any way to do this. How can I calculate Netmask/Gateway from an IP Block?
The ip address is logical and'ed with the subnet_mask. The subnet_mask can be used to carve out many net_id. Read here for an example: http://www.garykessler.net/library/subnet_masks.html.
You can calculate the ip and mask using something like this: