Display IPv4 network information for given address and netmask.
Split networks, calculate subnetnetworks and supernetworks and convert address range.
Install required software
Install ipcalc
utility.
$ sudo apt-get install ipcalc
Display IPv4 network information
Display 10.0.0.1/8
network information.
$ ipcalc 10.0.0.1/255.0.0.0
Address: 10.0.0.1 00001010. 00000000.00000000.00000001 Netmask: 255.0.0.0 = 8 11111111. 00000000.00000000.00000000 Wildcard: 0.255.255.255 00000000. 11111111.11111111.11111111 => Network: 10.0.0.0/8 00001010. 00000000.00000000.00000000 HostMin: 10.0.0.1 00001010. 00000000.00000000.00000001 HostMax: 10.255.255.254 00001010. 11111111.11111111.11111110 Broadcast: 10.255.255.255 00001010. 11111111.11111111.11111111 Hosts/Net: 16777214 Class A, Private Internet
Display 172.16.0.1/12
network information.
$ ipcalc 172.16.0.1/12
Address: 172.16.0.1 10101100.0001 0000.00000000.00000001 Netmask: 255.240.0.0 = 12 11111111.1111 0000.00000000.00000000 Wildcard: 0.15.255.255 00000000.0000 1111.11111111.11111111 => Network: 172.16.0.0/12 10101100.0001 0000.00000000.00000000 HostMin: 172.16.0.1 10101100.0001 0000.00000000.00000001 HostMax: 172.31.255.254 10101100.0001 1111.11111111.11111110 Broadcast: 172.31.255.255 10101100.0001 1111.11111111.11111111 Hosts/Net: 1048574 Class B, Private Internet
Display 192.168.0.1/16
network information.
$ ipcalc 192.168.0.1/16
Address: 192.168.0.1 11000000.10101000. 00000000.00000001 Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000 Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111 => Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000 HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001 HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110 Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111 Hosts/Net: 65534 Class C, Private Internet
Display 84.16.240.28/26
network information.
$ ipcalc 84.16.240.28/26
Address: 84.16.240.28 01010100.00010000.11110000.00 011100 Netmask: 255.255.255.192 = 26 11111111.11111111.11111111.11 000000 Wildcard: 0.0.0.63 00000000.00000000.00000000.00 111111 => Network: 84.16.240.0/26 01010100.00010000.11110000.00 000000 HostMin: 84.16.240.1 01010100.00010000.11110000.00 000001 HostMax: 84.16.240.62 01010100.00010000.11110000.00 111110 Broadcast: 84.16.240.63 01010100.00010000.11110000.00 111111 Hosts/Net: 62 Class A
Display IPv4 subnetworks and supernetworks information
Calculate IPv4 supernetwork.
$ ipcalc 10.120.25.1/24 /18
Address: 10.120.25.1 00001010.01111000.00011001. 00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 10.120.25.0/24 00001010.01111000.00011001. 00000000 HostMin: 10.120.25.1 00001010.01111000.00011001. 00000001 HostMax: 10.120.25.254 00001010.01111000.00011001. 11111110 Broadcast: 10.120.25.255 00001010.01111000.00011001. 11111111 Hosts/Net: 254 Class A, Private Internet Supernet Netmask: 255.255.192.0 = 18 11111111.11111111.11 000000.00000000 Wildcard: 0.0.63.255 00000000.00000000.00 111111.11111111 Network: 10.120.0.0/18 00001010.01111000.00 000000.00000000 HostMin: 10.120.0.1 00001010.01111000.00 000000.00000001 HostMax: 10.120.63.254 00001010.01111000.00 111111.11111110 Broadcast: 10.120.63.255 00001010.01111000.00 111111.11111111 Hosts/Net: 16382 Class A, Private Internet
Calculate IPv4 subnernetworks.
$ ipcalc 10.120.25.1/24 /25
Address: 10.120.25.1 00001010.01111000.00011001. 00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 10.120.25.0/24 00001010.01111000.00011001. 00000000 HostMin: 10.120.25.1 00001010.01111000.00011001. 00000001 HostMax: 10.120.25.254 00001010.01111000.00011001. 11111110 Broadcast: 10.120.25.255 00001010.01111000.00011001. 11111111 Hosts/Net: 254 Class A, Private Internet Subnets after transition from /24 to /25 Netmask: 255.255.255.128 = 25 11111111.11111111.11111111.1 0000000 Wildcard: 0.0.0.127 00000000.00000000.00000000.0 1111111 1. Network: 10.120.25.0/25 00001010.01111000.00011001.0 0000000 HostMin: 10.120.25.1 00001010.01111000.00011001.0 0000001 HostMax: 10.120.25.126 00001010.01111000.00011001.0 1111110 Broadcast: 10.120.25.127 00001010.01111000.00011001.0 1111111 Hosts/Net: 126 Class A, Private Internet 2. Network: 10.120.25.128/25 00001010.01111000.00011001.1 0000000 HostMin: 10.120.25.129 00001010.01111000.00011001.1 0000001 HostMax: 10.120.25.254 00001010.01111000.00011001.1 1111110 Broadcast: 10.120.25.255 00001010.01111000.00011001.1 1111111 Hosts/Net: 126 Class A, Private Internet Subnets: 2 Hosts: 252
Split IPv4 network
Split 192.168.1.0/24
to two networks of size 126
hosts.
$ ipcalc 192.168.1.0/24 --split 126 126
Address: 192.168.1.0 11000000.10101000.00000001. 00000000 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000 HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001 HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110 Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111 Hosts/Net: 254 Class C, Private Internet 1. Requested size: 126 hosts Netmask: 255.255.255.128 = 25 11111111.11111111.11111111.1 0000000 Network: 192.168.1.0/25 11000000.10101000.00000001.0 0000000 HostMin: 192.168.1.1 11000000.10101000.00000001.0 0000001 HostMax: 192.168.1.126 11000000.10101000.00000001.0 1111110 Broadcast: 192.168.1.127 11000000.10101000.00000001.0 1111111 Hosts/Net: 126 Class C, Private Internet 2. Requested size: 126 hosts Netmask: 255.255.255.128 = 25 11111111.11111111.11111111.1 0000000 Network: 192.168.1.128/25 11000000.10101000.00000001.1 0000000 HostMin: 192.168.1.129 11000000.10101000.00000001.1 0000001 HostMax: 192.168.1.254 11000000.10101000.00000001.1 1111110 Broadcast: 192.168.1.255 11000000.10101000.00000001.1 1111111 Hosts/Net: 126 Class C, Private Internet Needed size: 256 addresses. Used network: 192.168.1.0/24 Unused:
Notice, it is 126
usable hosts addresses, so it does not include network and broadcast addresses.
Split 10.30.10.1/24
to three networks of size 6
, 50
and 25
hosts.
$ ipcalc 10.30.10.1/24 --split 6 50 25
Address: 10.30.10.1 00001010.00011110.00001010. 00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 10.30.10.0/24 00001010.00011110.00001010. 00000000 HostMin: 10.30.10.1 00001010.00011110.00001010. 00000001 HostMax: 10.30.10.254 00001010.00011110.00001010. 11111110 Broadcast: 10.30.10.255 00001010.00011110.00001010. 11111111 Hosts/Net: 254 Class A, Private Internet 1. Requested size: 6 hosts Netmask: 255.255.255.248 = 29 11111111.11111111.11111111.11111 000 Network: 10.30.10.96/29 00001010.00011110.00001010.01100 000 HostMin: 10.30.10.97 00001010.00011110.00001010.01100 001 HostMax: 10.30.10.102 00001010.00011110.00001010.01100 110 Broadcast: 10.30.10.103 00001010.00011110.00001010.01100 111 Hosts/Net: 6 Class A, Private Internet 2. Requested size: 50 hosts Netmask: 255.255.255.192 = 26 11111111.11111111.11111111.11 000000 Network: 10.30.10.0/26 00001010.00011110.00001010.00 000000 HostMin: 10.30.10.1 00001010.00011110.00001010.00 000001 HostMax: 10.30.10.62 00001010.00011110.00001010.00 111110 Broadcast: 10.30.10.63 00001010.00011110.00001010.00 111111 Hosts/Net: 62 Class A, Private Internet 3. Requested size: 25 hosts Netmask: 255.255.255.224 = 27 11111111.11111111.11111111.111 00000 Network: 10.30.10.64/27 00001010.00011110.00001010.010 00000 HostMin: 10.30.10.65 00001010.00011110.00001010.010 00001 HostMax: 10.30.10.94 00001010.00011110.00001010.010 11110 Broadcast: 10.30.10.95 00001010.00011110.00001010.010 11111 Hosts/Net: 30 Class A, Private Internet Needed size: 104 addresses. Used network: 10.30.10.0/25 Unused: 10.30.10.104/29 10.30.10.112/28 10.30.10.128/25
It will leave three unused networks: 10.30.10.104/29
(6 hosts), 10.30.10.112/28
(14 hosts) and 10.30.10.128/25
(126 hosts).
Convert IPv4 address range to CIDR notation
Convert IPv4 address range of 10.100.10.0
to 10.100.10.255
.
$ ipcalc 10.100.10.0-10.100.10.255
deaggregate 10.100.10.0 - 10.100.10.255 10.100.10.0/24
Convert IPv4 address range of 84.16.240.0
to 84.16.240.63
.
$ ipcalc --range 84.16.240.0 84.16.240.63
deaggregate 84.16.240.0 - 84.16.240.63 84.16.240.0/26
Additional options
Use --nobinary
option to supress the bitwise output.
$ ipcalc --nobinary --nocolor 84.16.240.1/26
Address: 84.16.240.1 Netmask: 255.255.255.192 = 26 Wildcard: 0.0.0.63 => Network: 84.16.240.0/26 HostMin: 84.16.240.1 HostMax: 84.16.240.62 Broadcast: 84.16.240.63 Hosts/Net: 62 Class A
Use --nocolor
option to disable color output.