Calculate Netmask/Gateway from IP Blocks
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? You can calculate the ip and mask using something like this: $ip_with_mask = '192.168.1.1/26'; list($ip, $mask_int) = explode('/', $ip_with_mask); $mask_nr = (pow(2, $mask_int