In this blog post I want to show you how ipcalc simplifies subnetting. When working on subnet addressing, we often have to look up and double-verify any address we deal with. Some of you have been doing this for so long that you can make all these calculations off the top of your head. But for most of us, it’s a cumbersome and time consuming task.
You can find many online tools to help you, but while working on the command line configuring routers and switches, having a command-line utility at the ready becomes very handy.
ipcalc is a utility that can perform simple manipulations of IPv4 addresses. If you just type “ipcalc” without any input option, it will give you a nice ‘help’ output with some examples which are very helpful to get you started.
Let’s look at some examples. If you give the IPv4 address as the input of your host, you will get the following output:
ipcalc picks up the netmask of the host and the output is pretty self explanatory. The nice thing about ipcalc is that it gives the binary equivalents for each address which helps you to better visualize it. If you don’t like that, or if you find it redundant, you can disable the binary output by using the “- -binary” option.
The coloring also helps visualize some important aspects such as the netmask and the class bits. If you want to get rid of the coloring (although I don’t see the reason why) you can add the “- -nocolor” option.
Finally, the gap in the binary representation separates the network and the host part of the address.
You can also give the netmask as input, and here is a simple example of that:
One of the most useful capabilities of ipcalc is its ability to calculate network segments. Here is an example of how this works when we want to assign 10 and 20 addresses to two different subnets:
Finally, you can get the output in HTML format by using the “- -html” option and just the bit-count-mask of an address with the “- -class” option.
An evolved version of ipcalc is ipv6calc which deals with all the complexities and new features introduced in IPv6. We’ll cover it in a future blog post.