<\/div>\r\n
The IPv4 Address Format<\/h2>\r\n
A binary digit is called a bit<\/strong>. It represents a 1 or a 0. An IPv4 address has 32 bits. The IP addressing scheme is written in ‘dotted decimal notation’ as four octets<\/strong> separated by periods, for example, 203.0.113.10 where ‘203’ is the 1st octet and ‘0’ is the 2nd octet etc.<\/p>\r\n32 bits in an IPv4 address, divided into 4 octets, means that there are 8 bits in each octet. Each octet can have a value ranging from 0 to 255.<\/p>\r\n
Our example IP address 203.0.113.10 can be written as ‘203.0.113.10’ in dotted decimal notation. This is the usual format when working with IP addresses and the format we use when entering commands on computers.<\/p>\r\n
The IP address 203.0.113.10<\/strong> can also be written as ‘11001011.00000000.1110001.00001010’<\/strong> in binary:<\/p>\r\n203<\/strong> in decimal is 11001011 in binary.<\/br>\r\n0<\/strong> is 00000000.<\/br>\r\n113<\/strong> is 1110001.<\/br>\r\n10<\/strong> is 00001010.<\/p>\r\nWe never use the binary format when entering commands, but it’s important to know how to calculate it in order to understand subnetting.<\/p>\r\n
So the 32-bit IPv4 address is written in dotted decimal notation as four 8-bit octets to make it easier for humans to work with.<\/p>\r\n
<\/div>\r\n
The Logical IP Address Space<\/h2>\r\n
A single giant network would be an unmanageable mess. IP networks are split into smaller ‘subnets’ to provide better performance, security, and scalability than would be possible with a single flat global address space. The IP address format enables this logical separation between networks.<\/p>\r\n
The IP address comprises two main parts, the network bits and the host bits. The subnet bits determine what network a device is on, and the host bits define the individual device in that network. All of the devices on the same subnet will have the same network bits and different host bits.<\/p>\r\n
Think of a telephone number. You have an area code and then the number. The area code can be thought of as the subnet bits. Many people who live near one another share an area code, but all have an individual phone number. The same is true of devices on a subnet. They all share the same subnet bits, but each has an individual combination of host bits.<\/p>\r\n
Which part of the IP address is the subnet part and which part is the host part is indicated using a subnet mask<\/strong>. A subnet mask (or netmask) is made up of 32 bits and looks similar to a regular IP address. It is used only to divide the subnet bits from the host bits.<\/p>\r\nThe subnet bits are set as 1s, and the host bits are set as 0s. So a subnet mask might be 11111111.11111111.1111111.00000000, which in decimal would be 255.255.255.0. This example subnet mask specifies that the first three octets are the subnet bits, and the last octet will be used for host bits.<\/p>\r\n
IP addresses can have their 1s and 0s mixed together in any order, such as our example IP address 203.0.113.10: 11001011.00000000.1110001.00001010.<\/p>\r\n
But the ‘1’s indicating the network bits in a subnet mask must always<\/strong> be in a contiguous block from left to right. For example, 11111111.11111111.11111111.00000000 is a valid subnet mask. 11101011.11011111.11000000.00000000 is an invalid subnet mask, and you would get an error message if you tried to use it.<\/p>\r\nOur example subnet mask can be written as 11111111.11111111.11111111.00000000 in binary, or 255.255.255.0 in dotted decimal notation, or \/24 in slash notation (if you count how many network bits there are from left to right, it equals 24).<\/p>\r\n
When a device wants to communicate with another device over an IP network, it checks whether the destination is on the same or a different subnet. It does this by comparing the destination IP address to its own IP address and subnet mask. (It is unaware of the subnet mask configured on the destination device and does not need to know this information.)<\/p>\r\n
<\/div>\r\n
Communication Within and Between Subnets<\/h2>\r\n
Let’s work through an example…<\/p>\r\n
PC1 has an IP address 203.0.113.10 and a subnet mask 255.255.255.0. The subnet mask is 11111111.11111111.11111111.00000000 in binary. The network portion of the address is the first 3 octets, so 203.0.113 is the network portion of the address, and 10 is the host portion. The IP address and subnet mask have been configured on PC1, so it knows this information.<\/p>\r\n
PC1 needs to communicate with PC2 at 203.0.113.20. It compares the network portion of its own address (203.0.113) with the destination IP address 203.0.113<\/strong>.20 and sees that they match, so it knows that PC2 is on the same subnet. It can communicate directly with PC2 without having to go via a router.<\/p>\r\nPC1 needs to communicate with PC3 at 192.168.30.10. It compares the network portion of its own address (203.0.113) with the destination IP address 192.168.30<\/strong>.20 and sees that they are different, so it knows that PC3 is on a different subnet. It needs to go via its default gateway router to communicate with PC3.<\/p>\r\nHosts in the same subnet address should all be configured with the same subnet mask, or there will likely be connectivity issues.<\/p>\r\n
Note that by coincidence, PC1 and PC3 have the same value for their host bits in our example (10). This is not a problem because they are on different subnets. Each device must have unique host bits within its own subnet, but devices in different subnets can have the same host bits.<\/p>\r\n
<\/div>\r\n
IP Address Classes and their Default Subnet Masks<\/h2>\r\n
When IPv4 was first introduced, the designers did not envision the explosive growth of the Internet. They designed it to be sufficient for the needs of that time with some room for growth, but nowhere near enough to handle the proliferation of IP-enabled devices such as PCs and mobile phones we see today.<\/p>\r\n
IPv4 supports 3 main ranges of IP Address Classes, which can be assigned to standard devices on networks. Each Address Class has a default subnet mask:<\/p>\r\n\r\n
\r\n\r\n\r\nClass<\/td>\r\n | Default Subnet Mask<\/td>\r\n | Range<\/td>\r\n<\/tr>\r\n |
\r\nClass A<\/td>\r\n | 255.0.0.0 (\/8)<\/td>\r\n | 1.0.0.0 – 126.255.255.255<\/td>\r\n<\/tr>\r\n |
\r\nClass B<\/td>\r\n | 255.255.0.0 (\/16)<\/td>\r\n | 128.0.0.0 – 191.255.255.255<\/td>\r\n<\/tr>\r\n |
\r\nClass C<\/td>\r\n | 255.255.255.0 (\/24)<\/td>\r\n | 192.0.0.0 – 223.255.255.255<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n Use the formula 2h minus 2 to calculate how many hosts any particular subnet supports, where h is the number of host bits. (The minus 2 is because the base network address and the broadcast address cannot be assigned to end hosts.)<\/p>\r\n A Class A<\/strong> address with the default subnet mask has 8 network bits, leaving 24 host bits. 224 minus 2 = 16777214. A Class A subnet with the default subnet mask supports up to 16777214 host addresses.<\/p>\r\nA Class B<\/strong> address with the default subnet mask has 16 network bits, leaving 16 host bits. 216 minus 2 = 65534. A Class B subnet with the default subnet mask supports up to 65534 host addresses.<\/p>\r\nA Class C<\/strong> address with the default subnet mask has 24 network bits, leaving 8 host bits. 28 minus 2 = 254. A Class C subnet with the default subnet mask supports up to 254 host addresses.<\/p>\r\n |