IP Calculation

Useful tools to calculate subnets and ranges

The math behind IP addresses is convoluted. Our nice IPv4 addresses start out as 32-bit binary numbers, which are then converted to base 10 numbers in four 8-bit fields. Decimal numbers are easier to manage than long binary strings; still, calculating address ranges, netmasks, and subnets is a bit difficult and error-prone, except for the brainiacs who can do binary conversions in their heads. For the rest of us, meet ipcalc and ipv6calc.

ipcalc is for IPv4 networks, and ipv6calc is for IPv6 networks.

Calculate using subnet

root@Kali:~# ipcalc 192.168.0.0/25 
Address:   192.168.0.0          11000000.10101000.00000000.0 0000000 
Netmask:   255.255.255.128 = 25 11111111.11111111.11111111.1 0000000 
Wildcard:  0.0.0.127            00000000.00000000.00000000.0 1111111 
=> 
Network:   192.168.0.0/25       11000000.10101000.00000000.0 0000000 
HostMin:   192.168.0.1          11000000.10101000.00000000.0 0000001 
HostMax:   192.168.0.126        11000000.10101000.00000000.0 1111110 
Broadcast: 192.168.0.127        11000000.10101000.00000000.0 1111111 
Hosts/Net: 126                   Class C, Private Internet 

Calculate using netmask

root@DESKTOP99:~# ipcalc 192.168.0.0 255.255.128.0 
Address:   192.168.0.0          11000000.10101000.0 0000000.00000000 
Netmask:   255.255.128.0 = 17   11111111.11111111.1 0000000.00000000 
Wildcard:  0.0.127.255          00000000.00000000.0 1111111.11111111 
=> 
Network:   192.168.0.0/17       11000000.10101000.0 0000000.00000000 
HostMin:   192.168.0.1          11000000.10101000.0 0000000.00000001 
HostMax:   192.168.127.254      11000000.10101000.0 1111111.11111110 
Broadcast: 192.168.127.255      11000000.10101000.0 1111111. 

Classful IP Ranges

E.g Class A,B,C (depreciated)

IPv4 Private Address Ranges

IPv4 Subnet Cheat Sheet

Subnet cheat sheet, not really related to pen testing but a useful reference.

Last updated