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
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||126.96.36.199 to 188.8.131.52||184.108.40.206 to 220.127.116.11||192.0.0.0 to 18.104.22.168|
|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|
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.
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.
|Size of Network Part of
Address in Bits
|Size of Host Part of
Address in Bits
|Default Mask for Each
Class of Network
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|
|10.0.0.0 through 10.0.0.0||A||1|
|172.16.0.0 through 172.31.0.0||B||16|
|192.168.0.0 through 192.168.255.0||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 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.
|Result of AND||22.214.171.124||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, 255.255.240.0. 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 255.255.240.0, 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.
Now an example. Given is an ip address 126.96.36.199/20 with the subnet mask 255.255.240.0. 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.
188.8.131.52 the next one is…
184.108.40.206 next one.
220.127.116.11 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 255.255.240.0
How many subnets are possible for the CIDR of 20. 256(magic number) divided by 16 = 16.
For the subnet mask 255.255.240.0 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. 255.255.255.192 and /25
B. 255.255.255.248 and /28
C. 255.255.255.224 and /26
D. 255.255.255.248 and /27
E. 255.255.255.240 and /28
F. 255.255.255.240 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 172.19.20.23/28
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. 172.19.20.0, 172.19.20.16 and 172.19.20.32.
The address 172.19.20.23 is between 172.19.20.16 and 172.19.20.32. The right answer is C.
4. A network administrator has subnetted the 172.16.0.0 network using a subnet mask of 255.255.255.192.
A duplicate IP address of 172.16.2.120 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 172.16.2.120.
This address are network addresses. The only only two right answers are 172.16.2.128
and 172.16.2.127. But 172.16.2.127 is the broadcast address for the subnet 172.16.2.64.
So one possible answer is correct. Answer B.