As a first post in my blog I will present you some work on IPv4 Adressing and Subnetting, which I originally made during a lecture in university.
This article deals with the adressing scheme of IPv4 and the ability of separating a given network into smaller subnets. Therefore at first a short primer on the IPv4 addressing scheme will be given and it will be described why it is desirable to build many subnets instead of one large network.
Furthermore the function of subnet mask and IP adress will be shown. After this the building of a subnet with static and variable subnet mask will be shown. An at last it will be demonstrated, how IP address and subnet mask can be altered.
Let us consider, a scenario in which we want to connect three or more end devices over an intermediate device. In this case it is not possible any longer to establish a direct cable connection between the end devices and we need to determine for every packet which end device is the destination. At this point the IPv4 address is used. The IP address is 32 bit long and every end device which wants to communicate over an IP network has to occupy one.
The IP address may be enough for serving source and destination for a communication, but if we consider that only one really large network exists, there would also be only one broadcast domain, which leads us to the problem, that a broadcast message, like it is produced by an ARP request, produces a number of responses, which cannot be handled any more. Also it is impossible to represent geographic or hierarchical structures. At this point the subnet mask, which also has a length of 32 bits, is called into action. Due to the subnet mask it becomes possible to divide a network into smaller subnets.
In an IPv4 network the address consists of 32 bit, which for a better presentation to the user is normally displayed in form of four integer values ranging from 0 to 255. Some of these 32 bits are used to determine in which network the host is located (the so called ‘Network Portion’) and some of these bits are used to identify the host itself inside of this subnetwork (the ‘Host Portion’). To determine, which of these bits are used for which purpose, the subnet mask is used. Besides this every network has two reserved addresses, which cannot be used by an host system. These two addresses are the network address, which determines the beginning of the network, and the broadcast address, which is the last address in every network and is used to send messages to every device in this network.
For resolving the network address the networking equipment is able to compute the network address from the full ip adress by simply AND-ing the ip address and the subnet mask. The process is shown in the figure below. Often in networking-related literature it is the case, that the subnet mask is directly appended to the network address, like 192.168.1.0/24. In this case the number on the right side of the slash tells the reader how much bits are used for the network portion.
Building the subnet
When divinding a larger network the administrator has two possible options for building the subnets. He either can use classful subnetting (Fixed Length) or classless subnetting (Variable Length).
Classful subnetting is the easier method, because the subnet mask only has to be computed once and is used for all subnets. Due to this fact all subnets are of the same size, which however is a wasteful variant, because you are not able to build special purpose mini subnets (like for router connections).
With classless subnetting this problem is solved, because subnets can be tailored to the number of users in the group, for which the subnet is set. Therefore different subnet masks are used.
Fixed Length Subnet Mask
A Fixed Length Subnet Mask is used in classful subnetting. Due to the fixed subnet mask all networks are of the same size. The process of classful subnetting is now described in detail.
Let us consider a network as shown in figure EX1. On the left we need enough addresses for 256 host. On the right we have a single host directly connected to Router1 and an additional network consisting of 20 hosts. Furthermore we have to bear in mind that we also have a network between the Router0 and Router1, which use a DCE serial connection. Our available network is 220.127.116.11/21 (subnet mask: 255.255.248.0). As we can see 11 bits are currently left for host adresses.
This leads us to the following requirements:
Net1 = 256 hosts
Net2 = 20 hosts
Net3 = 2 hosts (Router1 ↔ Router 0)
Net4 = 2 hosts (Router1 ↔ PC1)
For building the subnet mask we have to take a look at the biggest subnet, which in this case has 256 hosts. After adding the broadcast and network adress we eventually need 258 adresses. Therefore we need 9 bit for assigning an address to every host in this network. This finally leads us to the following:
So our resulting network has the following configuration:
Overall subnet mask: 255.255.254.0
Net1: 18.104.22.168 (BC: 22.214.171.124)
Net2: 126.96.36.199 (BC: 188.8.131.52)
Net3: 184.108.40.206 (BC: 220.127.116.11)
Net4: 18.104.22.168 (BC: 22.214.171.124)
As it becomes obvious we are possible to solve the above described problem, but due to the enormous difference of the net sizes we waste many addresses (e.g. In Net3 for example 508 addresses are wasted).
Variable Length Subnet Mask
A better aproach for building a subnet is the classless subnetting, because the subnet masks in this aproach have a variable length, which means, that you can combine very large networks and very small networks without a enormous waste of address space. For using VLSM the network should at least support RIP v2, OSPF, EIGRP, Dual IS-IS or BGP.
Now we will again build a subnet for our demo configuration (details on this configuration can be found above), but this time we will utilize VLSM.
In a first step we have to find out how much bits each of our networks will need for addressing all hosts inside:
|| Req. Hosts
|| Req. Hosts + Structure
|| Bits needed
|| Max. Hosts
After having found out, how much bits we need for the representation of the host portion and fitting the individual subnets to the smallest possible size, it should be obvious, that this principle will save us a lot of address space. In the next step we have to calculate the network address, the subnet mask and the broadcast addresses for each of the subnets.
This leads us to the following result:
|| Network Address
|| Subnet Mask
|| Broadcast Address
Viewing and changing IP Address and Subnet mask
In the following section the methods for setting and viewing the ip address and the subnet mask are shown.
On a windows machine the user has several possibilities to change the ip address. The first way is to go to locate the symbols for the active network interfaces and then modifying their configuration by selecting the properties of the IPv4 protocol for this device. The configuration window of Windows 7 is shown beneath.
A faster accessible way is using the command-line of the windows system. Then the user is able to manipulate and view the settings with either the tool ipconfig or netsh, which also allows to import and export the interface settings.
For further information on netsh please refer to: netsh explanation
The typical output of ipconfig is shown below.
Every linux-based machine comes with the ifconfig tool, which allows it to either simply show the configuration of the network interfaces or manipulate the settings for each interface by using the command-line.
For further information please refer to: ifconfig explanation
Network Fundamentals, V4.0, Cisco Networking Academy
IP Adressing and Subnetting Workbook, V1.5, Cisco Networking Academy
VLSM – Variable-Length Subnet Mask Workbook, V1.1, Cisco Networking Academy