Ipcalc actually does a lot more – it takes an IP address and netmask and provides the resulting broadcast, network, Cisco wildcard mask, and host range. You can also use it as a teaching tool to present subnetting results in an easy to understand binary values.
Some of the uses of ipcalc are:
- Validate IP address
- Show calculated broadcast address
- Display hostname determined via DNS
- Display network address or prefix
How to install ipcalc in Linux
To install ipcalc, simply run one of the commands below, based on the Linux distribution you are using.
$ sudo apt install ipcalc
The ipcalc package should be installed automatically under CentOS/RHEL/Fedora and it is part of the initscripts package, but if for some reason it is missing, you can install it by using:
# yum install initscripts #RHEL/CentOS # dnf install initscripts #Fedora
How to Use ipcalc in Linux
Below you can see some examples of using ipcalc.
Get information about the network address:
# ipcalc 192.168.20.0
Sample Output
Address: 192.168.20.0 11000000.10101000.00010100. 00000000 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 192.168.20.0/24 11000000.10101000.00010100. 00000000 HostMin: 192.168.20.1 11000000.10101000.00010100. 00000001 HostMax: 192.168.20.254 11000000.10101000.00010100. 11111110 Broadcast: 192.168.20.255 11000000.10101000.00010100. 11111111 Hosts/Net: 254 Class C, Private Internet
Calculate a subnet for 192.168.20.0/24.
# ipcalc 192.168.20.0/24
Sample Output
Address: 192.168.20.0 11000000.10101000.00010100. 00000000 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 192.168.20.0/24 11000000.10101000.00010100. 00000000 HostMin: 192.168.20.1 11000000.10101000.00010100. 00000001 HostMax: 192.168.20.254 11000000.10101000.00010100. 11111110 Broadcast: 192.168.20.255 11000000.10101000.00010100. 11111111 Hosts/Net: 254 Class C, Private Internet
Calculate a single subnet with 10 hosts:
# ipcalc 192.168.20.0 -s 10
Sample Output
Address: 192.168.20.0 11000000.10101000.00010100. 00000000 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 192.168.20.0/24 11000000.10101000.00010100. 00000000 HostMin: 192.168.20.1 11000000.10101000.00010100. 00000001 HostMax: 192.168.20.254 11000000.10101000.00010100. 11111110 Broadcast: 192.168.20.255 11000000.10101000.00010100. 11111111 Hosts/Net: 254 Class C, Private Internet Calculate a single subnet with 10 hosts: # ipcalc 192.168.20.0 -s 10 Sample Output Address: 192.168.20.0 11000000.10101000.00010100. 00000000 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111 => Network: 192.168.20.0/24 11000000.10101000.00010100. 00000000 HostMin: 192.168.20.1 11000000.10101000.00010100. 00000001 HostMax: 192.168.20.254 11000000.10101000.00010100. 11111110 Broadcast: 192.168.20.255 11000000.10101000.00010100. 11111111 Hosts/Net: 254 Class C, Private Internet 1. Requested size: 10 hosts Netmask: 255.255.255.240 = 28 11111111.11111111.11111111.1111 0000 Network: 192.168.20.0/28 11000000.10101000.00010100.0000 0000 HostMin: 192.168.20.1 11000000.10101000.00010100.0000 0001 HostMax: 192.168.20.14 11000000.10101000.00010100.0000 1110 Broadcast: 192.168.20.15 11000000.10101000.00010100.0000 1111 Hosts/Net: 14 Class C, Private Internet Needed size: 16 addresses. Used network: 192.168.20.0/28 Unused: 192.168.20.16/28 192.168.20.32/27 192.168.20.64/26 192.168.20.128/25
If you want to suppress the binary output, you can use the -b option as shown.
# ipcalc -b 192.168.20.100
Sample Output
Address: 192.168.20.100 Netmask: 255.255.255.0 = 24 Wildcard: 0.0.0.255 => Network: 192.168.20.0/24 HostMin: 192.168.20.1 HostMax: 192.168.20.254 Broadcast: 192.168.20.255 Hosts/Net: 254 Class C, Private Internet
To find more about the ipcalc usage, you can use:
# ipcalc --help # man ipcalc