Routing and Switching

IPv4 Subnetting

Subnetting is the method whereby one large network is broken down into smaller networks. It’s also the creation of many networks from one network address. The smaller networks created from one large network are called subnetworks. Subnetworks or subnets as it’s often called, are logically defined group of smaller networks represented by the same network and subnet ID in the IP address. Subnetworks are created by taking bits from the host portion of the IP address and reserve them to define subnet address.

For example, consider a corporate company having Accounting, Human Resources, and Legal Affairs departments. These departments can be split into logical groupings of smaller networks that still reside in the overall corporate network. The company can make use of the class B address 172.16.0.0, assign 172.16.1.0, 172.16.2.0 and 172.16.3.0 respectively to each of the departments.

Subnetting makes it easier to manage a network and also keep problem restricted to the portion of the network where they emanate. To create a subnet, take the following steps

  1. Determine the number of required network IDs:
  • One for each subnet.
  • One for each wide area network connection.
  1. Determine the number of required host IDs per subnet:
  • One for each TCP/IP host
  • One for each router interface
  1. Based on the above requirements, create the following:
  • One subnet mask for your entire network
  • A unique subnet ID for each physical segment
  • A range of host IDs for each subnet.

By default, network devices have no idea which part of the host address will be used as the subnet address, this will prevent the subnet address scheme from working as intended. To overcome this problem a subnet mask is assigned to each machine.

A subnet mask is a 32-bit value that enables recipients of IP packets to distinguish the network ID portion from the host ID portion of the address. It is composed of 0’s and 1’s, the 1’s represent the network or subnet portion of the address and the 0’s bit refers to the host bit of the address.

All classes of address have a default subnet masks which cannot be changed. Class A subnet mask can’t be given to a class B network and a class C network subnet mask can’t be used for class A. The table below shows the default subnet mask for the most used class of addresses.

Class Format Default subnet mask
A network.node.node.node 255.0.0.0
B network.network.node.node 255.255.0.0
C Network.network.network.node 255.255.255.0

The subnet mask bound each class of IP to have a prefixed number of network and a prefixed number of hosts per network.

Classless Inter-domain Routing (CIDR)

CIDR is an addressing scheme that permit efficient allocation of internet addresses than was possible with the use of class-based address allocation format leading to an increase in the number of internet addresses. CIDR is based on Variable Length Subnet Mask (VLSM), which allows a network to be divided into variously sized subnets more appropriately for local needs.

Back in the early days, allocation of internet addresses are class-based – class A, B & C. Each of this class of IP is divided into two parts; the network and host part and have a definite number of networks and hosts as described in an earlier post. This allocation of addresses based on the class of the IP leads to address wastage. For example, if you needed 120 addresses you’d be assigned a class C address that provides 254 addresses, an excess of 134 unused addresses. What a waste!

The concept of CIDR was introduced to address the issue of address wastage. It overcomes the problem of being limited to the 8, 16 & 24 prefixes. It’s allows the use of prefixes anywhere from 13 – 27. The advantage of this is that an organization   with just 30 hosts and an organization with 500,000 host can get addresses suitable for their specific needs without unnecessary waste of addresses.

According to the CIDR standard, the first part of an IP address is the prefix which identifies the network. This is then followed by the host identifier so that packets can be sent to specific computers within the network.

Shortly after the introduction of CIDR, network admins were finding it difficult to track and label IP addresses. To overcome this a notation system was developed to make the system more efficient and standardized. The system is called the CIDR notation. This notation is indicated by the slash (/) symbol. With CIDR notation we can no longer identify a particular class by examining the octets alone. With CIDR, the IP address is followed with the amount of bits assigned as the network ID, often called the prefix length.

A CIDR address includes the standard 32-bit IP addresses and also the information on how many bits are used for the network prefix. For example, in the address 210.15.3.48/25, the /25 indicates that the first 25 bits are used to identify the network, and the remaining bits are used for host identification.

SUBNETTING EXAMPLES

Class C Subnetting

There are 4 bytes or 32 bits in an IPv4 address, divided into four sections and separated by dotted decimal notation. Each section contain 1 byte or 8 bits, a bit can either be on or off. 1 represent a bit turned on and 0 represent a bit turned off. Subnet bits start at the left and go to the right without skipping a bit. The following subnet masks belong to class C IP address:

Binary Decimal CIDR
00000000 0 /24
10000000 128 /25
11000000 192 /26
11100000 224 /27
11110000 240 /28
11111000 248 /29
11111100 252 /30

/31 and /32 can’t be use because there need to be at least 2 host bits for assigning IP addresses to hosts.

After a subnet mask has been chosen for our network we need to determine the number of subnets, valid hosts, and broadcast addresses that our chosen mask provides. We can get all these by answering the following five questions:

  • How many subnets does the chosen subnet mask produce?
  • How many valid hosts per subnet are available?
  • What are the valid subnets?
  • What’s the broadcast address of each subnet?
  • What are the valid hosts in each subnet?

Now let’s answer these questions:

  • How many subnets?

Number of subnets = 2x, where X = number of bits turned on or 1’s

For example, 11100000, the number of 1’s is 3 so we have 23 subnets which equals 8 subnets.

  • How many valid host per subnet?

Number of hosts per subnet = 2y – 2, where y is the number of bits turned off or 0’s. The subtracted 2 addresses represent the network and broadcast addresses which are not valid hosts. So in 11100000, we have 25 – 2 hosts which equals 30 hosts per subnet

  • What are the valid subnets?

Valid subnets = 256 – subnet mask, this gives us the block size or increment number.

For example, 256 – 224 = 32. So now we know the block size of the 224 mask is always 32.

To get the valid subnets produced by this mask start counting at zero in blocks of 32 until the subnet mask value is reached. From our example we have 0, 32, 64, 96, 128, 160, 192, and 224. There goes our valid subnets.

  • What’s the broadcast address of each subnet?

The broadcast address of each subnet is the number right before the next subnet. From our previous example, the 0 subnet have a broadcast address of 31 because the next subnet is 32, the 32 subnet have a broadcast of 63 for the same reason stated above, and on and on. The last subnet is always 255.

  • What are the valid hosts?

The valid hosts are the numbers between the subnet address and the broadcast address. For example, if 0 is the subnet number and the broadcast is 31, the valid host are 1 – 30. Again, for subnet number 32, broadcast address is 63, thus valid host are 33 – 62.

Class C Subnetting Practice

#1C: 255.255.255.128 (/25)

The subnet mask /25 is 10000000 in binary, it gives 1 bit for subnetting and 7 bits for host addressing. Let’s subnet the class C address 192.168.20.0.

Network address = 192.168.20.0

Subnet mask = 255.255.255.128

Let’s put the five questions to use:

  • How many subnets?

We have a single bit turned on (10000000), so the answer would be 21 = 2 subnets

  • How many hosts per subnet?

There’s 7 host bits turned off (10000000), so we’d have 27 – 2 = 126 hosts

  • What are the valid subnets?

256 – 128 = 128. We’d start at zero and count in a block size of 128 until the subnet mask is reached. 0, 128.

  • What’s the broadcast address for each subnet?

The broadcast address is the number right before the next subnet. The 0 subnet will have a broadcast address of 127 and 255 for the 128 subnet.

  • What are the valid hosts?

The valid host are numbers between the subnet and broadcast addresses. See the table below.

Subnet 0 128
First host 1 129
Last host 126 254
Broadcast 127 255

This same process will be followed for all other subnet masks in class C IP address.

Class B Subnetting

Class B network address provides 16 bits for host addressing, but we can only use 14 bits for subnetting because we have to leave at least 2 bits for defining hosts. All the possible subnet mask for class B are as follows:

Subnetting a class B network is the same as it is for class C except there are more host bits and we start from the third octet. Here, we use the same subnet numbers for the third octet with class B that we use for the fourth octet with class C, but a zero is added to the network portion and a 255 to the broadcast section in the fourth octet.

Class B subnetting Practice

#1B: 255.255.128.0 (/17)

Network address = 172.16.0.0

Subnet mask = 255.255.255.128

  • How many subnets?

21 = 2

  • Hosts per subnets?

215 – 2 = 32,766              (7 bits in the third octet and 8 bits in the fourth octet)

  • Valid subnets?

256 – 128 = 128. 0, 128

Here’s what’s different, we did the subnetting in the third octet so the subnets are actually 0.0 and 128.0

  • Broadcast address for each subnet?

127.155 for the 0.0 subnet and 255.255 for the 128.0 subnet.

  • Valid hosts?

These are numbers between the subnet and the broadcast address. See table below

Subnet 0.0 128.0
First host 0.1 128.1
Last host 127.254 255.254
Broadcast address 127.255 255.255

This same method is used for subnetting class A IP address with the only difference being that subnetting begins in the second octet and there are 24 bits available. It’s very important that upon looking at an IP address and a subnet mask that you’re able to distinguish between bits used for subnetting from bits used for hosts addressing.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s