This blog is going to serve as a simple guide to IPv4 addressing. Even though the *RIPE NCC has run out of IP address space to allocate (just two days ago as I write this), IPv4 remains relevant and is something you’ll have to deal with if you’re interconnecting network devices. There are after all a lot of IPv4 addresses allocated with private addresses being used over and over again.

*RIPE (Réseaux IP Européens), NCC (Network Co-ordination Centre).

IP address format

An IPv4 address consists of 32 binary bits so mathematically there is a maximum of 2^32 or 4,294,967,296 addresses. After we take out things like broadcast addresses, private addresses, and special-use addresses like multicasts, we’re left with around 3.7 billion addresses (according to Cisco).

To make IP addresses easier to read, they are split into 4 groups of 8 bits each separated by a dot and converted to decimal format. Now the maximum number of combinations that can be represented by eight binary bits is 256, (including 0) so the maximum decimal number, if all the bits are set to 1 would be 255.
To see the IP address of a Windows machine you can open a command prompt and type in “ipconfig” or “ipconfig /all”. For Linux use “ifconfig” in a terminal window to output something similar.

A simple guide to IPv4 addressing, example output from the windows "ipconfig" command
Example “ipconfig” output from the command prompt of a Windows 10 computer

So an IP address looks like the following “” when written in human-readable form. In binary (since a binary value can only be a 0 “unset” or a 1 “set”) that would be “00001010.11111010.00010101.00011111”.

Now binary values, as with decimal notation increase in value the further to the left they are. Each position to the left doubles the value of the one next to it. For example, the Least Significant Bit ( the bit furthest to the right, which has the lowest value) can be either unset 0 or set 1, when it is set, it represents a decimal 1 (actually 2 to the power of 0 which we write as 2^0). When the next bit to the left is set, ie 1, the decimal value it represents will be 2 (2 to the power of 1, or 2^1) and if we go on further to the left the decimal values represented are 4, 8, 16, 32, 64, and 128 (increasing in powers of 2 thus 2^2=4, 2^3=8, 2^4=16 and so on until we reach 2^7=128).

So for the IP address in our example, the first number 10 is made up of the set bits representing 8 and 2 hence 8+2=10. Followed by the others below

Binary bit values   Decimal equivalent and total value
128 64 32 16 8 4 2 1
0 0 0 0 1 0 1 0 8+2=10
1 1 1 1 1 0 1 0 128+64+32+16+8+2=250
0 0 0 1 0 1 0 1 16+4+1=21
0 0 0 1 1 1 1 1 16+8+4+2+1=31

Identifying the network and the host addresses

The IP address is split into two components, the network part, and the host part.
When IPv4 was first introduced the network space was separated into classes that could be identified by inspecting the address. Class A, B, and C were allocated for public and private address space that could be used for network hosts (with some exceptions), while class D was for multicast addresses. Class E was reserved.

Class A networks used decimal values from to
Class B networks used decimal values from to
Class C networks used decimal values from to
Class D networks used decimal values from to

These values are not random, but align with the binary numbering system and we can identify which class of addresses the number relates to by inspecting the first three (most significant) bits of the first octet of the address. We need to look at the first four bits to identify class E addresses.

Lowest value - Highest value   Decimal values Class
0 0 0 0 0 0 0 0 - 0 1 1 1 1 1 1 1 0 - 127 A
1 0 0 0 0 0 0 0 - 1 0 1 1 1 1 1 1 128 - 191 B
1 1 0 0 0 0 0 0 - 1 1 0 1 1 1 1 1 192 - 223 C
1 1 1 0 0 0 0 0 - 1 1 1 0 1 1 1 1 224 - 239 D
1 1 1 1 0 0 0 0 - 1 1 1 1 1 1 1 1 240 - 255 E

So class A addresses always have the most significant bit (MSB) set to 0, class B addresses always have the second most significant bit set to 0 while class C addresses have the third most significant bit always set to 0.

The subnet mask

An IPv4 address is always paired with what’s called a subnet mask. The subnet mask defines which bits in the IP address belong to the network and which bits belong to the host.
The original IPv4 specification defined default subnet masks for each class as follows.

Class Number of network bits Subnet mask dot decimal Subnet mask CIDR
A 8 /8
B 16 /16
C 24 /24

Where the subnet mask bit is set to 1, the corresponding bit in the IP address is considered to belong to the network, and where the subnet mask bit is 0, the corresponding IP address bit belongs to the host.
By default then, for a class A address, the first octet is the network address and the rest (octets 2 to 4) can be used for hosts. Similarly, for default class B addresses the first two octets belong to the network and the last two octets belong to the hosts. Class C, has the first three octets reserved for the network with the last octet for hosts.

So for our class A address with a default mask of, the ’10’ is our network part and the host part is ‘250.21.31’. The 10 part would be common on all hosts on the network but the rest could be any number. There are two exceptions, which are the subnet address (sometimes referred to as the subnet-zero address) and the subnet broadcast address which in this case is
If we had a class C address such as then with the default mask, the network part of the address would be ‘192.250.21’ which would be common to all the hosts on the network, leaving only the last octet available.

This means the number of hosts on the network will vary depending on the subnet mask. For a class C network, only the last octet is available for hosts so the maximum number of hosts is 256 minus 2 (the unavailable subnet and broadcast address). So we can have up to 254 hosts on a class C network.
For a default class B network such as 128.250.21, there are two octets available so we have 256 times 256 (65,536) subtract the subnet and broadcast and we can have 65,534 hosts. For class A networks we can have up to 16,777,214 hosts (256*256*256-2)

The subnet mask also reflects the number of networks available. If we use the defaults then a class A IP address can have 2^7 networks, since the first bit is always set to ‘0’ leaving 7 bits remaining for network addressing, 0 to 127 in decimal format or 128 networks. In practice 0 isn’t used so we have 127 class A networks by default. For class B and C we can have 2^14=16,384 and 2^21=2,097,152 networks respectively.

Classless IPv4 addressing (CIDR)

CIDR or Classless Inter-Domain Routing was introduced in 1993 to replace the classful network design of the previous system. It essentially decouples the default mask from the IP address and allows for smaller subnets or larger supernets.

IP addresses and subnet masks can be written in dot-decimal notation or CIDR notation ‘’ can be written as ‘’.
Note that the default mask would be, or a slash 24 (/24) for a 192 address. In this case, we have split the last octet into two networks by allocating 1 extra bit to the network.
We can tell how many bits are allocated by looking at the subnet mask, 1 bit = 128, 2 bits =128+64=192, 3 bits=128+64+32=224 and so on.
We can also tell how many hosts are on the network by subtracting the subnet mask from the number of possible hosts (256). For the example below, if we look at the CIDR mask of /25 we subtract 128 from 256 which gives us 128 and since we have to subtract 2 addresses for subnet and broadcast, it leaves us with 126 useable host addresses. We can’t use the /31 or /32 masks for the last octet (but you may see these addresses appear in routing tables).

Subnet bits Class equivalent CIDR Dot decimal value No of hosts No of networks
2^(32-no of subnet bits)-2 2^(no of subnet bits)
1 All Supernet /1 2,147,483,646 2^1=2
2 All Supernet /2 1,073,741,822 2^2=4
3 All Supernet /3 536,870,910 2^3=8
4 All Supernet /4 268,435,454 2^4=16
5 All Supernet /5 134,217,726 2^5=32
6 All Supernet /6 67,108,862 2^6=64
7 All Supernet /7 33,554,430 2^7=128
8 A Normal, B/C Supernet /8 16,777,214 2^8=256
9 A Subnet, B/C Supernet /9 8,388,606 2^9=512
10 A Subnet, B/C Supernet /10 4,194,302 2^10=1,024
11 A Subnet, B/C Supernet /11 2,097,150 2^11=2,048
12 A Subnet, B/C Supernet /12 1,048,574 2^12=4,096
13 A Subnet, B/C Supernet /13 524,286 2^13=8,192
14 A Subnet, B/C Supernet /14 262,142 2^14=16,384
15 A Subnet, B/C Supernet /15 131,070 2^15=32,768
16 A Subnet, B Normal, C Supernet /16 65,534 2^16=65,536
17 A/B Subnet, C Supernet /17 32,766 2^17=131,072
18 A/B Subnet, C Supernet /18 16,382 2^18=262,144
19 A/B Subnet, C Supernet /19 8,190 2^19=524,288
20 A/B Subnet, C Supernet /20 4,094 2^20=1,048,576
21 A/B Subnet, C Supernet /21 2,046 2^21=2,097,152
22 A/B Subnet, C Supernet 22 1,022 2^22=4,194,304
23 A/B Subnet, C Supernet /23 510 2^23=8,388,608
24 A/B Subnet, C Normal /24 254 2^24=16,777,216
25 A/B/C Subnet /25 126 2^25=33,554,432
26 A/B/C Subnet /26 62 2^26=67,108,864
27 A/B/C Subnet /27 30 2^27=134,217,728
28 A/B/C Subnet /28 14 2^28=268,435,456
29 A/B/C Subnet /29 6 2^29=536,870,912
30 A/B/C Subnet /30 2 2^30=1,073,741,824
31 A/B/C Subnet /31 0 2^31=2,147,483,648
32 A/B/C Subnet /32 0 2^32=4,294,967,296

So with classless subnetting, you can choose the number of networks and hosts to suit the environment. If you are restricted to a specific prefix but need to segment it, you can do it with classless subnetting. Alternatively, you can also do what’s called super-netting by removing bits from a subnet mask which has can have the effect of adding classful subnets together. The following combination ‘’ or ‘’ results in the two, class C subnets ‘’ and ‘’ being joined in a contiguous network from ‘’ through to ‘’

Subnet Calculators

Of course, if you’re just allocating a few private IP address ranges for a home network you might not want to worry about non-default subnets and just stick with one class C or if you want to access a home server from the Internet and choose to have a DMZ (demilitarized zone), perhaps two or more class C networks.

If you do choose to subnet, you can use a subnet calculator, even if it’s only to confirm that your choices and calculations are valid and that you haven’t selected something that isn’t going to work.

There are a number of such programs developed for iPhones (such as Subnet Calculator +) and for Android (ipv4 subnet calculator or IP network calculator), I’m currently using Subnet Calculator by Mecbe.

Most often though, I use an excel spreadsheet on my computer. It also works with google sheets, although it’s missing some sliders, so while it is possible to use it with a phone, I wouldn’t recommend it.

I’m making the spreadsheet available online as a freebie if it’s of use to anyone, and I’ll put up some screenshots and pointers here.

The Techiedoodah IPv4 Excel Subnet Calculator

The Techiedoodah Excel IPv4 subnet calculator is shown below. It is open on the Calcs sheet where you enter the IP address and subnet mask you wish to work with.

An image showing the Techiedoodah IPv4 subnet calculator excel .xlsx spreadsheet open on the Calcs sheet.
The Techiedoodah IPv4 subnet calculator .xlsx spreadsheet.

Most of the cells are locked. You can change the Subnet bits (1) either by typing in a value or clicking on the sliders to the right. Changing the subnet bits/prefix value will change the Subnet mask and the red bar below the “Classless network” title will move accordingly. It will also change the values in “Subnet Address” and “Broadcast Address” if they would be affected by the prefix change.
In the image above the sheet is showing that the current subnet prefix results in a “Supernet” since the classful default for a 172 address is to use a 16-bit mask, so we have 16 contiguous class networks encompassed by the above /12 prefix and they cover from to We can also see how many networks and how many hosts per network we can have, although the number of networks is the theoretical maximum since it includes public address space.
You can also change the IP address (2) which will alter the values of the Binary and Hexadecimal addresses at 3. Using the sliders at point 3. will also change the Binary and Hexadecimal addresses as well as the IP addresses in the sheet.

The image below shows what happens when we change the prefix to 19 from 12. The subnet mask has changed from to, the subnet address has changed as well as the broadcast address, the number of networks and hosts, wildcard mask and the red bar below “Classless network”. Notice also that the “Supernet” tag has disappeared.

Changing the subnet prefix in the Techiedoodah IPv4 subnet calculator excel .xlsx spreadsheet.
Changing the subnet prefix on the Techiedoodah IPv4 subnet calculator .xlsx spreadsheet.

The image below shows what happens if we use a subnet mask that is not restrictive enough and includes address space from private, public and “zero-configuration” space.

 The Techiedoodah IPv4 subnet calculator showing conflicting address space in a single subnet.
The Techiedoodah IPv4 subnet calculator showing conflicting address space in a single subnet.

The Allocation sheet shows what problems might be found in the address range included by the currently selected prefix and address combination. Note that the bar on the left shows which IP ranges are included. This would be green if there were no problems.

The Techiedoodah IPv4 subnet calculator showing subnet problems on the allocation sheet.
The Techiedoodah IPv4 subnet calculator showing subnet problems on the allocation sheet.

Going to the Subnets sheet we can see the subnet addresses for our subnet (in black) together with the other available subnet ranges. In the case of a /19 prefix, we have eight possible subnets if we keep the first two octets the same.

 The Techiedoodah IPv4 subnet calculator showing the Subnet sheet.
The Techiedoodah IPv4 subnet calculator showing the Subnet sheet.

The Address Ranges sheet just includes links to RFC pages and to the Wikipedia page about classful network ranges. It’s included for reference. The data included are subject to change.

The spreadsheet does require the Analysis ToolPak Add-In for the Binary address and Hexadecimal address sections to work so if you have problems with those cells please read the instructions in the Subnet Calculator text box.

This spreadsheet is provided by Techiedoodah “as is” and “with all faults.” Techiedoodah makes no representations or warranties of any kind concerning the safety, suitability, lack of viruses, inaccuracies, typographical errors, or other harmful components of this spreadsheet. There are inherent dangers in the use of any files downloaded from the Internet, and you are solely responsible for determining whether this spreadsheet is compatible with your equipment and other software installed on your equipment. You are also solely responsible for the protection of your equipment and backup of your data, and Techiedoodah will not be liable for any damages you may suffer in connection with using, modifying, or distributing this spreadsheet.

Do virus check the spreadsheet, it’s not macro enabled and does not contain macros so if you get the spreadsheet with a .xlsm instead of a .xlsx extension then be wary.

While the sheets in the spreadsheet are protected, you can turn off that protection, there is no password.

You are free to make any changes to the spreadsheet as desired and distribute as you wish but please keep the links in for the Techiedoodah website.

The SHA256 checksum for the file is 173BEA8F7FE4F8CF5176FF25DE8B7C9E23F2C1119DBB355A81542BD287F12872

To cut a long story short, a summary.

Despite the fact that RIPE has run out of public IPv4 addresses for allocation, IPv4 still needs to be managed and configured in the real world. Whether it’s using private address space for a home network, or something larger, it helps to know how the IP address relates to the subnet mask and which parts belong to the network and which parts are available for host addresses.

To aid the choice and creation of subnets we can make use of IPv4 subnet calculators. There are apps and programs available for iPhone, Android as well as for Linux and Windows such as the Free Solarwinds tool.

There’s also the Techiedoodah IPv4 subnet calculator spreadsheet available for free by subscribing to the newsletter in the form above.

If you’re a network engineer and you get a lot of time hands on rackside and need a tray to put your laptop on, let us know what you think of the Portable Rack Mount Laptop Tray and sign up if you want one. Type with two hands instead of one, be more comfortable, improve your productivity and get out of the server room sooner, (or wherever the rack happens to be).

Techiedoodah blogs are created in the hope that they can help others by giving real-life examples. If this has been useful to you please feel free to leave a comment. If you’re reading this post on the home page, you won’t be able to post comments here, so follow this link to the blog, and then scroll to the comments section at the bottom of the page.