ipcalc – Removing the brain work from subnetting calculations

Written by James McDonald

July 2, 2008

I’ve just been nosing around the Fedora 8 /etc/sysconfig/network-scripts/network-functions script and noticed a call to a utility named ipcalc.

Seeing as I usually spend quite some time trying to figure out how to calculate the correct subnets for a given subnet mask this utility makes it easy.

For example:

Given an ipaddress in this style (CIDR)

You can basically discern all the important network information:
1. The network address that it’s on
ipcalc -n

2. What the broadcast address is for that network
ipcalc -b

3. The network mask
ipcalc -m

Once you have the above you can by inference discern the host addresses also.

So if I know the NETWORK address which from above it is add 1 to get the first host:

Knowing the BROADCAST address I subtract 1 to get the last host:

With ipcalc you can add all the flags to get the information in one hit:
ipcalc -b -m -n

In this example with a 29 bit netmask the first host would be = and the last host would be =

ipcalc is part of a default Fedora 8 installation. Installation under Ubuntu is simply sudo apt-get install ipcalc.

However the ipcalc installed by Ubuntu gives all the information you would need in one hit:

Address: 11000000.10101000.00000001.00000 010
Netmask: = 29 11111111.11111111.11111111.11111 000
Wildcard: 00000000.00000000.00000000.00000 111
Network: 11000000.10101000.00000001.00000 000
HostMin: 11000000.10101000.00000001.00000 001
HostMax: 11000000.10101000.00000001.00000 110
Broadcast: 11000000.10101000.00000001.00000 111
Hosts/Net: 6 Class C, Private Internet


Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Network speed test host to host

On Ubuntu / Debian apt-get install iperf3 On Windows download it from https://iperf.fr/iperf-download.php#windows Make...

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...