Subnetting

In case of class A and B IP addresses, each of them provides for a large number of hosts. For class A, the total numbers of hosts available are 224-2 or 16,777,216 hosts (class A has 24 bits available for host component and each bit can have two values – 0 and 1. Out of the total value one address is for network address and the other for broadcast. So two addresses are deducted). Similarly a Class B addresses provides for 216-2 or 65,534 hosts. In the first chapter you learned about disadvantages of large networks and why it becomes necessary to divide them into smaller networks joined by routers. So creating a network with total number of hosts allowed for class A or B addresses will cause a lot of problems. Meanwhile creating small networks with class A or B addresses will waste a lot of addresses.

To overcome this problem with class based addressing, subnetting was introduced. Subnetting allows you to borrow some host bits and use them to create more networks. These networks are commonly called subnets and are smaller in size. But since each network has a network address and a broadcast address, some addresses get wasted.

To further understand how subnetting is useful consider a Class C address. Each class C address has 28-2 or 254 host addresses available. If you wanted 2 networks with 100 addresses and used 2 class C networks, you would waste 308 addresses. Instead of using two class C networks, you can subnet one to provide you two networks of 126 addresses each. This way lesser number of addresses would be wasted.

While some of the benefits of subnetting are discussed above, the following list discusses all the benefits associated with it:

◉ Reduced broadcasts – While broadcasts are necessary, too many of them can bring down a network and the number of broadcasts is proportionate to the size of the network. So subnetting a network to smaller subnetworks, helps reduce broadcasts since routers do not forward broadcasts.
◉ Increased Network Performance – The direct result of reduced broadcasts is a network that has more bandwidth available to the hosts. More bandwidth and lesser hosts result in a better performance of the network.
◉ Easier Management – Managing and troubleshooting a large network is cumbersome and difficult. Subnetting breaks a network into smaller subnetworks, making it easier to manage each of them.
◉ Scalability – A single large network spanning a large geographical location will be more difficult and costlier to manage. WAN links connecting different locations are costly and having broadcasts choking the network can result is wasted money. Hence breaking down a large network makes is easier to scale a network across geographical locations.

Now that you understand the concept and benefit of subnetting, consider the problem that arises with it. In case of class based subnetting, the first octet of the dotted decimal address tells which part of the address is the network component and which one is the host component. But when host bits are borrowed for subnetting, the class based boundaries do not apply and it is not possible to say which bits are network bits. To overcome this, a third component of IP addresses were added. These are called the subnet masks.

Subnets masks, like IP addresses, are 32 bit long. The value of subnet mask represents which bits of the IP address are network components and which are host component. A value of 1 in a subnet mask shows that the corresponding bit in the IP address is a network component while a value of 0 shows that the corresponding bit is a host component. The following examples will help clarify this further:

1. An IP address of 192.168.10.1 with a subnet mask of 255.255.255.0 (11111111.11111111.11111111.00000000) shows that the first three octets of the IP address are the network component while the last octet is the host component.

2. An IP address of 172.16.100.1 with a subnet mask of 255.255.128.0 (11111111.1111111.100000000.00000000) shows that one bit from the third octet has been borrowed from the host component. Hence the network component is now 17 bits long instead of the default 16 bit in a class B address.

3. An IP address of 10.1.1.1.1 with a subnet mask of 255.255.0.0 (11111111.11111111.00000000.0000000) shows that the entire second octet has been borrowed from the host component and now the network component is 16 bits long instead of the default 8 bit of a class A address.

One restriction that applies to subnet masks is that all network bits (1) and all host bits (0) should be contiguous. So a subnet mask of 11001100.11110000.11110000.00001111 is not valid because the network and host bits are not contiguous. Table 2-5 shows the valid subnet mask values is an octet.

Table 2-5 Valid subnet mask values in an octet

Binary Value Decimal Value
00000000
10000000 128 
11000000 192 
11100000 224 
11110000 240 
11111000 248
11111100 252
11111110 254
11111111 255

Subnets masks are commonly represented in two ways:

1. Dotted Decimal – 10.1.1.1 255.255.0.0
2. Classless Inter-Domain Routing (CIDR) notation – 10.1.1.1/16

Exam Alert: It is very important to be able to understand subnet masks with both the dotted decimal as well as the CIDR format. Also remember that any mask not given in Table 2-5 is not valid for an octet.

By now you may have figured out that the default subnet mask of class A is 255.0.0.0 or /8, the default mask of class B is 255.255.0.0 or /16 and the default mask of class C is 255.255.255.0 or /24. Table 2-6 shows the default masks of each class. These default masks cannot be changed. For example, you cannot use a mask of 255.255.0.0 for a class C address. If you try to use an invalid mask such as this, every device will produce an error. For each class, the minimum mask is the default mask and it cannot be reduced. Class A has to have a minimum mask of 255.0.0.0, class B has to have a minimum mask of 255.255.0.0 and class C has to have a minimum mask of 255.255.255.0.

Table 2-6 Default Subnet masks

Class Format Default Subnet Mask
A network.host.host.host 255.0.0.0
network.network.host.host 255.255.0.0
network.network.network.host 255.255.255.0

Remember that an IP address without mask or a mask without IP address does not mean anything. A mask of /24 does not mean that the address is a class C address. Even a class A or class B address can have a mask of /24 after subnetting. Table 2-7 provides a list of dotted decimal subnet mask value and the corresponding CIDR value.

Table 2-7 Subnet Mask values

Dotted Decimal Value CIDR notation
255.0.0.0  /8
255.128.0.0 /9 
255.192.0.0 /10 
255.224.0.0 /11 
255.240.0.0 /12 
255.248.0.0 /13 
255.252.0.0 /14 
255.254.0.0 /15 
255.255.0.0 /16 
255.255.128.0 /17 
255.255.192.0  /18 
255.255.224.0  /19 
255.255.240.0  /20 
255.255.248.0  /21 
255.255.252.0  /22 
255.255.254.0  /23 
255.255.255.0  /24 
255.255.255.128  /25 
255.255.255.192  /26 
255.255.255.224  /27 
255.255.255.224  /28 
255.255.255.248   /29 
255.255.255.252  /30 

Before moving to actual subnetting, you need to remember the powers of 2 i.e. the value of 2 multiplied as many times as the given exponent. For example 24 = 2 x 2 x 2 x 2 = 16. Table 2-8 lists the first 14 values. It is not necessary to remember them all, but do remember that each value is twice the previous one. The more you remember these values, the easier it will be to subnet on your CCNA exam

Table 2-8 Powers of Two

Exponent Value
2(1) 2
2(2)
2(3)
2(4) 16 
2(5) 32 
2(6) 64 
2(7)  128 
2(8) 256 
2(9) 512
2(10) 1024
2(11) 2048
2(12) 4096
2(13) 8192
2(14) 16384

Now that you know what subnetting is and how subnet masks are used, it is time to create subnets. When planning to subnet, you need to know three things:

1. Total number of subnets that you need
2. Total number of hosts per subnet that you need
3. Available network and subnet mask (which will be subnetted)

Armed with answers to this, you need to find the following:

1. Subnet Mask to be used across the network
2. Valid subnets
3. Network address for each subnet
4. Broadcast address for each subnet
5. Valid host addresses in each subnet.

For this section I will take a sample requirement of 8 networks with 30 hosts each with one class C network of 192.168.10.0 255.255.255.0 available. Now that you have the requirement, first thing you need to find is the new subnet mask that can satisfy the requirement. To find the subnet mask, follow the steps given below:

1. Find the exponent of 2 whose value is more than or equal to the number of subnets required. Lets call this 2sn. For our example, we need 8 subnets and 23 equals to 8. So our 2sn is 23.

2. Find the exponent of 2 whose value minus 2 is more than or equal to the maximum number of hosts required in a subnet. Lets call this (2h-2) For our example, we need a maximum of 30 hosts in a subnet and 25-2 gives us 30 hosts per subnet.

3. Make sure sn + h from the above two steps does not exceed the number of host bits available in the network available. If the sum of sn and h exceed the available host bits then you will require another network of the same class or a network of a higher class. In our example we have 8 bits of host addresses available in 192.168.10.0 255.255.255.0 network. Our sn+h is 3+5 that gives us 8.

4. Convert the available mask to the CIDR notation and add sn to it to get the new subnet mask. For our example the mask 255.255.255.0 can be converted to /24. On adding 3 we get a mask of /27. Converting from /27 to the dotted decimal format is easy. /24 is 255.255.255.0 or 11111111.1111111.1111111.00000000. /27 will be 11111111.1111111.1111111.11100000. You need not worry about the first 3 octets since they are already known to be 255.255.255. For the last octet add the decimal value for each network bit. In our case it will be 128+64+32 = 224. So the new subnet mask is 255.255.255.224. Table 2-7 also provides a list of dotted decimal and networking bits value.

The most difficult part is now over. To find the rest of the 4 answers, follow the steps given below:

1. Valid subnets – To find the valid subnets deduct the interesting octet value from 256. Interesting octets are those octets that have host bits. Available subnets will be in multiples of the resultant value up to 256. In our case the fourth is the interesting octet. Deducting 224 from 256 gives us 32. So the available subnets are 0,32, 64, 96, 128, 160, 192, 224.

2. Network Address of each subnet – The network address is the very first address of each subnet. So for our valid subnets, the network address would be 192.168.10.0, 192.168.10.32, 192.168.10.64, 192.168.10.96, 192.168.10.128, 192.168.10.160, 192.168.10.192 and 192.168.10.224

Exam Alert: Sometime back Cisco used to discard the first and the last subnet, also called subnet zero. So the number of subnets used to be 2n-2. Starting IOS version 12.0 the ip subnet-zero command is enabled by default and in Cisco exams the first and last subnets are considered unless specified otherwise. Be on the lookout for questions on your CCNA exam that ask you not to consider subnet zero. In such cases, leave out the first and the last subnet. To fully understand how the command affects the calculation, consider a Class C network with a mask of /26. It will give you subnets 0, 64, 128 and 192 if subnet-zero is allowed, else it will only give you subnets 64 and 128.

3. Broadcast Address of each subnet – The last address of a subnet is the broadcast address. Simply deduct 1 from the next network address to find the broadcast address of a subnet. For our example subnets the valid broadcast addresses are:

Network Address Broadcast Address
192.168.10.0 192.168.10.31
192.168.10.32 192.168.10.63
192.168.10.64 192.168.10.95
192.168.10.96 192.168.10.127
192.168.10.128 192.168.10.159
192.168.10.160 192.168.10.191
192.168.10.192 192.168.10.223
192.168.10.224 192.168.10.255

4. Valid hosts addresses in each subnet – For every subnet, the valid host addresses lie between the network address and the broadcast address. For our example, the valid host addresses for each subnet are:

0 comments:

Post a Comment