Linux IP Subnetting Tools

unnamedIP subnetting is one of the core topics that is covered in the CCNA and is something that every network engineer worth his/her salt will be able to do in their head. Having said that though, there are times when you just cant be bothered to do it in your head, we are human after all and by default lazy.

There are tonnes of web-based subnetting tools out there, a quick google search came up with following:

They are all pretty good and get the job done, but being as lazy as I am why would I want to go to the hassle of opening a browser and going to a bookmark, or worse running a google search, when I am usually already logged into the most powerful tool of them all, the Linux Bourne Again SHell (Bash). In this post i will be going through the installation and operation of a few of the most popular bash cli IP subnetting tools that are out there.


Whatmask, a small C program from Laffey Computer Imaging, is my personal favourite, for IPv4 subnetting, out of all the tools listed in this post. What mask is light and provides the required information in a neat, readable format. The downside to whatmask is that it currently only supports IPv4 subnetting.

Install Whatmask

To install whatmask you will need to download latest source tarball from Laffey Computer Imaging. At the time of writing the latest version is 1.2 I usually do all my downloads for new programs into my ~/Downloads folder:

Next we need to configure and install the source tarball we just downloaded:

Running Whatmask

Whatmask can be run in two modes:

  1. Using only a subnet mask as an argument.
  2. Using any IP address and subnet mask combination. The subnet mask can be input either in Dotted Decimal notation (DDN) or in CIDR notation.

The syntax to run whatmask is as follows:

Mode 1: Subnet Only

When running whatmask in the first mode, with only a subnet mask as an argument, you will get the following details:

  • Netmask CIDR notation.
  • Netmask DDN notation.
  • Netmask in HEX.
  • Wildcard mask.
  • Number of usable IP’s in the subnet.

In the following example I will use a /21 CIDR notation mask and a DDN notation mask:

Sample output for /21 as an argument:

Sample output for as an argument:

Mode 2: IP/Subnet

When running whatmask in the second mode, with both an IP address and subnet mask as arguments, you will get the following details:

  • The netmask in the following formats: CIDR, Netmask, Netmask (Hex), Wildcard Bits
  • The Network Address
  • The Broadcast Address
  • The number of Usable IP Addresses
  • The First Usable IP Address
  • The Last Usable IP Address

In the following example I will be using CIDR notation and DDN notation as the arguments.

Sample output using

Sample output using as arguments:

As you can see whatmask provides its output in an easy to read format with all the information you could possibly want to answer those pesky subnetting questions. For more details on what you can do with whatmask check out the man page.


The second IP subnetting program we will be looking at is sipcalc. Sipcalc is an advanced console based ip subnet calculator, created by Simon Ekstrand, that has support for both IPv4 and IPv6 addresses. Sipcalc is feature rich when compared with whatmask and is useful especially as you can grab the subnet information straight form an interface on a server.

Currently Sipcalc has the following features:

IPv4 –

  • Multiple address and netmask input formats.
  • Retrieving of address information from interfaces.
  • Classful and CIDR output.
  • Multiple address and netmask output formats (dotted quad, hex, number of bits).
  • Output of broadcast address, network class, Cisco wildcard, hosts/range, network range.
  • Output of multiple types of bitmaps.
  • Output of a user defined number of extra networks.
  • Multiple networks input from command line.
  • Parsing of a newline separated list of networks from standard input (STDIN).
  • The ability to “split” a network based on a smaller netmask, now also with recursive runs on the generated subnets.
  • DNS resolution.

IPv6 –

  • Compressed and expanded input addresses.
  • Compressed and expanded output.
  • Standard IPv6 network output.
  • v4 in v6 output.
  • Reverse DNS address generation.
  • The ability to “split” a network based on a smaller netmask, now also with recursive runs on the generated subnets.
  • DNS resolution.
Installing Sipcalc

The installation of sipcalc in Ubuntu or Debian based distro’s is as simple sa issuing the apt-get install sipcalc command:

Running Sipcalc

Sipcalc can accept input in three forms:

  • An IP address/ Subnet mask.
  • An interface.
  • Via stdin using the special character -.

Sipcalc accepts the following formats of addresses for input:

IPv4 –

The IP address must be in DDN, while the mask can be either:

  • CDIR notation.
  • DDN notation.
  • HEX.

IPv6 –

IPv6 addresses can be input in any of the forms defined in RFC2373.

Interface –

Sipcalc can obtain relevant information by looking at a specified interface on the system. Sipcalc then uses this information to calculate output values. This option is currently only available for IPv4 addresses.


IPv4 –

In the following examples we will use the same addresses that we used to test whatmask, CIDR notation and DDN notation, so that we can compare the output.

Sample output for

Sample output for

As I mentioned in the features, sipcalc can accept multiple addresses as inputs which means we can use a single command to output the details of both addresses mentioned above:

IPv6 –

In the following example we will gather the subnet information for 2001:7F8:19:1::3b41:1/64:


Lastly we will display the subnet information from an interface, in my case the wlan0 interface on my laptop:


The last IP subnet calculator we will be looking at is ipcalc written by Krischan Jodies. Ipcalc takes an IPv4 address and netmask and calculates the resulting broadcast, network, Cisco wildcard mask, and host range. By giving a second netmask, you can design sub- and supernetworks. It is also intended to be a teaching tool and presents the results as easy-to-understand binary values. Ipcalc is IPv4 only at the moment.

Install Ipcalc

Like sipcalc ipcalc is as easy to install as issue an apt-get install command:

Running ipclac

The syntax for running ipcalc is as follows:

The options can be any of the following:

  • -b, –nobinary Suppress the bitwise output
  • -c, –class Just print bit-count-mask of given address
  • -h, –html Display results as HTML
  • -s, –split n1 n2 n3. Split into networks of size n1, n2, n3
  • -r, –range Deaggregate address range

We will use the same addresses as we used for whatmask and sipcalc, CIDR notation and DDN notation, so you can compare the outputs:

Sample output

Ipcalc can also be used to split a given subnet into smaller subnets of your choosing. In this example I want to get a /29,/30 and /28 from the supernet

Ipcalc can also be used to deagregate a range of IP addresses into the largest possible networks. In this example I will deagregate the – range:

Each of the tools does things slightly differently but as you can see they each have their specific uses. Whatmask is great for a clear readable IPv4 break down with just the required details. Sipcalc is great for IPv6 and getting the subnet details from an interface. Ipcalc is really good for study purposes with the amount of information it outputs.

I hope that this has been helpful and will speed up the process of subnetting for you in your day-to-day duties. As always if you have any problems with installing the applications or with the commands quoted in the post, please let me know and I will try my best to help you.



Leave a Reply