cisco hands-on experience

IP Addressing and Subnetting

IP Addressing and Subnetting is the most basic understanding for a systems engineer to calculate networks and used hosts in an LAN/WAN environment. We will give you basic knowledge and show you how to calculate subnets in a few seconds with mental arithmetic. After the explanation of subnetting you will be able to get ready for some examples to reinforce the learned stuff showed on that site.

When you get familiar in subnetting, you will love this subject and never need a subnet calculator anymore.

Lets start with the basics
figure 1.1
Possible Valid Network Numbers

Figure 1.1 gives you a short clear view about valid Network and Hosts numbers. But you don’t have to remember this diagram at all.
This is only for the first impression of subnetting.

Class A Class B Class C
First Octet Range 1 to 126 128 to 191 192 to 223
Valid Network Numbers to to to
Number of Networks in This Class 27 – 2 214 221
Number of Hosts Per Network 224 – 2 216 – 2 28 – 2
Size of Network Part of Address (Bytes) 1 2 3
Size of Host Part of Address (Bytes) 3 2 1
figure 1.2
IP Addresses and Their Formats

Figure 1.2 shows the structure of the following three IP addresses, each from a different network. In this case no subnetting is used. This is called a classful network.
You only use the subnetmask 8; 16 and 24.

Class A

Network(8) Host(24)
8 1 4 5

Class B

Network(16) Host(16)
130 4 110 1

Class C

Network(24) Host(8)
199 1 2 3
figure 1.3
Network and Host Parts and Default Masks

Figure 1.3 shows the Network Part respectively the Host Part and its default Mask for each
Class of Network. For a better understanding the numbers where highlighted with different colours.

Class of
Size of Network Part of
Address in Bits
Size of Host Part of
Address in Bits
Default Mask for Each
Class of Network
A 8 24
B 16 16
C 24 8
figure 1.4
Private Address Space

Figure 1.4 shows the private address range. They are never used for routing over the internet.
If this ranges are uses over the Internet, you have to use NAT or. PAT for this purposes. NAT and PAT will be described in an other topic.

Private IP Networks Class of Networks Number of Networks through A 1 through B 16 through C 256

Boolean AND Operation

The calculation of an ip address with this subnetmask work with the Boolean AND Operation.
The following figure will show the results and the functionality.

x0 x1 y
0 0 0
0 1 0
1 0 0
1 1 1
The subnet mask has the function to look if a host is in the same network/subnet or if the request to the destination have to go over its gateway. If a host only communicate in the same network, you don’t need a gateway.

x0 stand for one bit in the ip address and x1 stand for one bit in the subnet mask.
Only if to bits have the value 1 the result will be 1. All other possible options put out the result 0.



A simple example.

Decimal 1.Oct 2.Oct 3.Oct 4.Oct
Address 10011011 10100110 00000010 00000011
MASK 11111111 11111111 11111111 00000000
Result of AND 10011011 10100110 00000010 00000000

Prefix Notation/CIDR Notation

Subnet masks are actually 32-bit numbers, but for convenience, they are typically written as dotted decimal numbers—for example, However, another way to represent a mask, called prefix notation, and sometimes referred to as CIDR notation, provides an even more succinct way to write, type, or speak the value of a subnet mask. To understand prefix notation, it is important to know that all subnet masks have some number of consecutive binary 1s, followed by binary 0s. In other words, a subnet mask cannot have 1s and 0s interspersed throughout the mask. The mask always has some number of binary 1s, followed only by binary 0s.
For the purpose of writing or typing the subnet mask, prefix notation simply denotes the number of binary 1s in a mask, preceded by a /. For example, for subnet mask, whose binary equivalent is 11111111 11111111 11110000 00000000, the equivalent prefix notation is /20, because there are 20 consecutive binary 1s in the mask.

To calculate the subnets in a mental arithmetic we need one important diagram.


  • The following diagram should be learned by heart.
figure 1.5
Decimal Binary value
128 10000000
192 11000000
224 11100000
240 11110000
248 11111000
252 11111100
254 11111110
255 11111111
At this point we need a virtual number called ‘magic number’. The magic number has a value of 256.

Now an example. Given is an ip address with the subnet mask 20 is the CIDR Number for 240. Take a look to the diagram. The number 240 has 4 bits active from the beginning of the left site. So we know the relevant digit to calculate. This is the 3rd Octet.

Because 8 (1.Oct) plus 8 (2.Oct) plus 4 (3.Oct) = 20. The sum is 20.
We take the magic number 256 and substract 240. The result is 16. Our network has an incremental respectively a step sequence of 16.

The first network (subnet) starts at. the next one is… next one. and so on…..


  • For mask bits from 0-8 the 1.Oct is relevant
  • For mask bits from 9-16the2.Oct is relevant
  • For mask bits from 17-24 the 3.Oct is relevant
  • For mask bits from 25-32 the 4.Oct is relevant


How many Hosts are possible for one subnet? We take the step sequence of 16 and multiplicate it with the maximum of possible Hosts from the 4.Oct.
The result will be (16 x 255) – 2 = 4078 Hosts are possible for one subnet with the mask

How many subnets are possible for the CIDR of 20. 256(magic number) divided by 16 = 16.
For the subnet mask there are 16 subnets possible.

Now lets do some exercises.

1. Which of the following correctly pairs the dotted decimal subnet mask with the correct number of binary bits that represent the subnet mask?

A. and /25
B. and /28
C. and /26
D. and /27
E. and /28
F. and /16

We know that all CIDR numbers are higher than 24. So the relevant Octet ist the 4th Octed.
Look at figure 1.5. 240 has 4 bits active. 8 (1.Oct) plus 8 (2.Oct) plus 8 (3.Oct) plus 4 (4.Oct) = 28.
The only correct answer is E.

2. What is the most efficient subnet mask for a small branch office with seven hosts?


We need 7 hosts. A step sequence number of 8 it’s not enought, because one of the address is the gateway address
and the other reserved address is for the subnet the broadcast address. The next higher sequence number is 16.
The right answer is C. (256 – 16 = 240)

3. What is the subnet address for the IP address


The CIDR is 28. Relevant Octet is the 4th Octet. The decimal number of CIDR 28 is 240 (figure 1.5).
256 – 240 = 16. We have a step sequence of 16. There are 3 subnet addresses., and
The address is between and The right answer is C.

4. A network administrator has subnetted the network using a subnet mask of
A duplicate IP address of has accidentally been configured on a workstation in the network. The technician must assign this workstation
a new IP address within that same subnetwork. Which address should be assigned to the workstation?


The right answer is a little bit tricky. We take the subnet mask (last Octet) and calculate the step sequence with the magic number.
256 – 192 = 64. Our step sequence is 64. We know the duplicat IP address is
This address are network addresses. The only only two right answers are
and But is the broadcast address for the subnet
So one possible answer is correct. Answer B.