How To Calculate Ip Subnet Address with Ipcalc

calculating ip subnet

If you’re working with Linux machines and want to manage a network, the bottom line is that you will need to get a handle on subnetting. 

Subnetting involves breaking down networks into much smaller networks. This helps improve routing efficiency and prevent network-wide threats from taking them down.

Managing subnetting requires calculating the subnet mask, which demands that binary math be performed with the IP address. This is where the ipcalc command comes in. 

The command essentially takes an IPv4 address and a netmask, then returns the full spectrum of the host’s IP information. Like any other command, ipcalc works with several options.  

In this brief guide, we’ll walk you through using the command to get the IP subnet address. 

Installing ipcalc

Try running the ipcalc –help to see whether it is installed on your machine. If the manual page appears, it’s worth going through the available options. 

If you don’t care about the options and want to get straight to the point, run “ipcalc -v” to find the version of the command on your machine. 

But if you see the “ipcalc not found” message, run the following command to initiate installation:

sudo apt install ipcalc

Enter your password if you’re demanded it, and your machine will handle the installation automatically. 

Finding the Network Address with ipcalc

To get the ipcalc command’s network address, supply the command with the IP address of which you want the information of, like so:

ipcalc 192.0.0.1

The output of the command will include the IPv4 address in binary and decimal formats. You will see four sets of 8-bit binary, all worked out by the command in under a second. 

To calculate the subnet mask for the same IP address, you must now pass the IPv4 address to the command:

ipcalc 192.0.0.1/24

You will then see the subnet address you are looking for. 

The Options You Can Use with ipcalc

The -s flag allows you to adjust the size or, more accurately, the number of hosts you want to see against a single subnet. So, if you were to run:

ipcalc 192.0.0.1 -s 10

The output will acknowledge the size of the host you requested, below which you will see the command’s calculated subnet. You can suppress the binary output to reduce the amount of information you have to deal with. 

To do this, you can use the -b option like so:

ipcalc -b 192.0.0.1

This will remove the binary address from the output. You will only see the decimal address in it. 

You can use the -r option to find the deaggregate address range of the IP address you have supplied. The deaggregate address range is the complete list of the addresses associated with the IP address. 

As you’d expect, using the option will give you an output of a large list of addresses related to the IP address. 

You can use several other options with the command, the details of all of which you will find if you run the –help command. You can use all the options in the same format we discussed above.

Conclusion

The billions of devices connected over the internet make tracking them challenging. The ipcalc command becomes invaluable when you need to work with subnetting, especially since it works with several options and offers a lot of flexibility when it comes to dealing with IP addresses.

Every ipcalc option supplies different types of information, so with this guide handy, you should quickly be able to find the information you need to accomplish what you’re aiming for.