A subnet is a contraction for the word “subnetwork,” meaning a smaller network carved from a larger network. Remember a big office building with many departments. In place of having one big department, the whole building is divided into smaller offices. In networking, a large network is then divided into small subnets to make management easy and performance efficient.
Essentially, subnetting is a very complex concept in networking; it’s quite necessary to learn how networks work. Basically, subnetting divides one large network into smaller chunks, often referred to as subnets, which can be much easier to deal with. It makes it easier to accommodate more organized and efficient networks, thereby possibly enhancing performance and security.
Important Terms to Understand
Before understanding subnetting and its process, it’s important to get proper understanding of the following terms:
- IP Address Structure
- IP Address Blocks
- Network vs. Host Portions
- Binary and Decimal Conversion
- Classful Addresses
- Subnet Mask
What is an IP address?
An IP address is rather like a phone number for your computer or other devices on the internet. It’s a unique identifier that helps other devices know where to send information.
IPv4 Addressing: Most IP addresses do take the form: 192.168.1.1. This is referred to as IPv4, standing for “Internet Protocol version 4.” IPv4 addresses are written in what is called dotted-decimal notation. Each address is subdivided into 4 parts, referred to as octets, separated by dots. Each part is a number between 0 and 255.
Pv6 Addressing This was introduced with the growth of the internet when we ran out of IPv4 addresses.
This is what IPv6 addresses would look like: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. IPv6 addresses are also composed of hexadecimal numbers (base16) and are divided by colons into 8 groups of 4 hexadecimal digits. IPv6 can provide a massive number of addresses compared to IPv4.
Why Use This Format?
- The numbers and dots (or colons in IPv6) help computers understand and manage addresses.
- Dividing the address into parts makes it easier to read and manage, especially for networks.
- The structure helps route information efficiently across the internet.
What Are IP Address Blocks?
An IP address block is a collection of IP addresses grouped together, much like a set of phone numbers that are managed as a unit. Instead of assigning each IP address individually, addresses are organized into blocks for easier management and allocation. This grouping simplifies handling a large number of addresses, improves organization by making it easier to allocate ranges to different networks or organizations, and enhances routing efficiency by streamlining the process of directing internet traffic.
In IPv4, which is represented by addresses like 192.168.1.1, blocks are defined by a starting address and a specified size. For example, the block `192.168.1.0/24` indicates a range of addresses beginning at 192.168.1.0 with a size that includes 256 addresses. The “/24” notation means that the block contains 256 unique addresses, making it easier to manage and allocate a range of addresses rather than dealing with them individually.
Diagram of an IPv4 Address Block:
Let’s look at a simple example of a block with a size of /29, which contains 8 addresses:
Points to remember
- IP Address Block: A range of IP addresses grouped together.
- IPv4: Address blocks like 192.168.1.0/24 contain a certain number of addresses.
- IPv6: Address blocks like 2001:0db8:85a3::/64 contain a very large number of addresses.
Network V/S Host Portion
In IP, every address given to a device is typically divided into two parts: Network Portion and Host Portion. The Network Portion or Network ID identifies the network on which the host resides while the Host Portion or Host ID identifies a single host in a given network. The subnet mask is used to mask the bits belonging to the network, and hence, it defines the Network Portion. The remaining bits, not masked, constitute the Host Portion. It is the division that plays an important role in routing data packets between devices on a network because it provides routers with the Network Portion for forwarding packets onto the appropriate network and the Host Portion to deliver packets to the correct device on that network. Here’s a diagram to illustrate this concept:
This diagram is the schematic representation of how the IP address is divided into two portions: the Network Portion and the Host Portion. The subnet mask determines the Network Portion of the IP address; the rest of the bits are the Host portion. The router will use the Network Portion to forward the packet to the correct network and use the Host Portion to deliver the packet to the correct device on that network.
Binary V/S Decimal
Binary is the method of counting and representing numbers by using only two digits: 0 and 1. It is somewhat a special number system that computers and other digital devices use in handling data. Think of binary as a very simple mechanism of an on-off switch, where 0 means off, 1 means on. This simplicity is what makes binary so effective for computers operating on electrical signals that can be either on or off.
Formally, each digit in binary is called a “bit,” short for “binary digit.” In practice, this means that while we go about normal, everyday counting using decimal digits-0 through 9-binary is designed to represent numbers using only 0 and 1. For example, in the decimal system, 2 is written as 2. In binary, it is written as 10. This is because binary counts in powers of 2 not in powers of 10. Here is how it works. In binary, each place value is a power of 2. So, in binary the number 2 is written as 1 0, that means 1 in the twos place and 0 in the ones place. If we add all of these up, we will have 2 in decimal.
To understand how binary numbers work, let’s look at a few more examples. The binary number 110 represents 1 times 4 (which is 2^2), plus 1 times 2 (which is 2^1), plus 0 times 1 (which is 2^0). Adding these values together, you get 6 in decimal. Similarly, the binary number 1011 represents 1 times 8 (2^3), plus 0 times 4 (2^2), plus 1 times 2 (2^1), plus 1 times 1 (2^0), which adds up to 11 in decimal.
Binary is fundamental to computers because they use a system of electrical circuits that can be either on or off, which maps perfectly to the 1s and 0s of binary. Every piece of data, from text and images to complex programs, is ultimately translated into a series of binary numbers so that the computer can process it. This binary system allows computers to perform complex calculations and store vast amounts of information efficiently. By breaking down everything into just 0s and 1s, computers can operate with incredible speed and precision.
How to Calculate Binary?
Counting in binary is quite different from counting in the decimal system that we use every day, but it’s not too difficult once you get the hang of it. Let’s start with the basics and build up from there. In binary, each place value represents a power of 2, just like each place value in decimal represents a power of 10.
In binary, the digits are only 0 and 1. Here’s how you count from 0 to 15 in binary:
- 0 in binary is just 0
- 1 in binary is 1
- When you reach the maximum value for a single digit (1), you add another digit, similar to how we carry over in decimal:
- 2 in decimal is represented as `10` in binary. This is because after 1, we need a new place value, just like how after 9 in decimal we move to 10.
To see this more clearly, let’s break it down step by step:
Let’s understand this with an example:
Decimal 3 to Binary:
- Write 3 in binary, start with the largest power of 2 that fits into 3, which is 2^1 (which equals 2).
- Subtract 2 from 3 to get 1. Now write a `1` in the place of 2^1 and `0` in the place of 2^2 (since 4 is too large).
- The remaining 1 is exactly 2^0, so write `1` in the place of 2^0.
- So, 3 in binary is `0011` (since 3 is made up of 2^1 + 2^0).
Counting Beyond 9:
When you count higher, just keep adding more binary digits (bits):
- 10 in decimal is `1010` in binary. This is because 10 is 8 (2^3) plus 2 (2^1).
- 15 in decimal is `1111` in binary. This is because 15 is 8 (2^3) + 4 (2^2) + 2 (2^1) + 1 (2^0).
Here’s a small diagram to visualize the counting:
Following this pattern allows one to count forever in binary just like we can in decimal – with just two symbols, the 0 and 1. And as you count higher you’ll add more digits just like we do in decimal when we increase past 9.
Classful Addresses
Classful addresses are a technique for organizing classes of IP addresses based on their size and use. This system was developed initially in the early days of the Internet as a convenient way of forcing order to be placed on IP address assignment and thus simplifying IP routing. Each IP address fits into one of several classes, and each class defines a range of addresses and potentially its intended use.
The five classes of main addresses are A, B, C, D, and E. Among them, Classes A, B, and C are used for ordinary network addressing, while Classes D and E are reserved for special purposes.
- Class A addresses are utilized when dealing with a very large network. Class A addresses range from `0.0.0.0` through `127.255.255.255`. The addresses in this range are divided into a few large-sized networks, each with a small number of host addresses. The first part of the address shows which network the user is on, and the rest identifies individual devices within that network.
- Class B is used for medium-sized networks. These range from `128.0.0.0` to `191.255.255.255`. In comparison with Class A, these addresses are divided into fewer networks, but each network can hold more devices. The first two parts of the address specify the network, and the last two parts identify the devices on that network.
- Class C addresses are used on smaller networks. Their range is from `192.0.0.0` to `223.255.255.255`. Class C addresses have even more networks compared to Class B, but on each network there are fewer addresses available to use for devices. The first three parts of the address identify the network and the last part identifies devices.
- Class D addresses range from `224.0.0.0` through `239.255.255.255`. These addresses are not used for normal network addresses but for sending data to many devices at once, such as sending a video stream to several users.
- Class E addresses, which go from `240.0.0.0` through `255.255.255.255`, are reserved for experimental use and also are not used in regular networking.
That classful system made IP address management easier in those days when networks were smaller and less complicated. As the Internet began to grow, and address needs also became complex, the classful system was replaced by a more flexible system known as classless addressing.
What is a subnet mask?
A subnet mask is a number that allows the calculation of the network portion in an IP address and the host portion. It does this by masking, or hiding, part of the IP address. For example, for the subnet mask 255.255.255.0, the ‘255’ parts are considered the network portion and the ‘0’ part the host portion.
Subnetting Process
Let’s walk through the process of subnetting using a simple example. Now, suppose you are given an IP address as 192.168.1.0 and you want to subdivide this address into several smaller-sized networks. Here is how this is done in general:
- You must determine how many subnets you need. Suppose you want to split your network into 4 subnets; you will need to change your subnet mask to do this.
- The subnet mask applied to the IP address 192.168.1.0 by default is 255.255.255.0. This mask allows you to have one large network with as many as 254 hosts. Since you want 4 subnets, then this must be changed to a more specific subnet mask. You could use the concept of subnetting bits. You need 2 bits to create 4 subnets because 2 to the power of 2 equals 4. When you add these 2 bits to the subnet mask, it becomes 255.255.255.192. Here’s why:
The original subnet mask 255.255.255.0 in binary is: 11111111.11111111.11111111.00000000
The new subnet mask 255.255.255.192 in binary is: 11111111.11111111.11111111.11000000
The added bits, 11000000, are used for subnetting.
- With the new subnet mask, you are able to calculate how many subnets you will have and how many hosts per subnet. Thus, with the use of the 255.255.255.192 mask, you get 4 subnets since 2 bits are borrowed for subnetting, and each subnet can contain 62 usable IP addresses for hosts since 6 bits are left for host addresses, giving 2^6 – 2 = 62 usable addresses.
- Break down the IP address range into the smaller subnets. For the 192.168.1.0 network with the 255.255.255.192 mask, the subnets would be:
– 192.168.1.0/26 (range: 192.168.1.1 to 192.168.1.62)
– 192.168.1.64/26 (range: 192.168.1.65 to 192.168.1.126)
– 192.168.1.128/26 (range: 192.168.1.129 to 192.168.1.190)
– 192.168.1.192/26 (range: 192.168.1.193 to 192.168.1.254)
Each of these ranges represents a separate subnet with its own set of IP addresses.
What are subnets used for?
Subnets help in several ways. They improve network performance by reducing traffic and congestion since devices within the same subnet can communicate directly without affecting other subnets. They also enhance security by isolating different network segments. For example, if you have separate subnets for different departments, you can control access between these departments, ensuring that sensitive data is better protected.
Subnetting also makes network management easier. By dividing a large network into smaller subnets, network administrators can troubleshoot problems more effectively, allocate IP addresses more efficiently, and manage network traffic better.
Subnetting examples can be quite varied. Let’s look at a couple more examples to illustrate how subnetting works in different scenarios:
- Example 1: Suppose you have a network 10.0.0.0 with a default subnet mask of 255.0.0.0 and you want to create 10 subnets. You would start by determining how many bits are needed to create these subnets. For 10 subnets, you need 4 bits (since 2^4 = 16, which is more than 10). The new subnet mask would be 255.240.0.0.
- Example 2: Consider you have a network 172.16.0.0 and you need 8 subnets. To achieve this, you need 3 bits (since 2^3 = 8). The new subnet mask would be 255.255.248.0. This subnet mask allows for 8 subnets, each with a certain number of hosts.
Understanding subnetting takes practice, but once you get the hang of it, it becomes an invaluable tool for network management. By knowing how to calculate subnet masks, determine IP ranges, and create subnets, you’ll be better equipped to design and manage efficient, secure, and well-organized networks.
How to calculate subnets with examples?
Example 1: Subnet Calculation
Scenario: An organization has been assigned the Class C network address `192.168.1.0` and uses a subnet mask of `255.255.255.224`. We need to determine which IP addresses are valid hosts within this subnet.
Solution:
- Convert the Subnet Mask to Binary:
`255.255.255.224` converts to binary as `11111111.11111111.11111111.11100000`.
- Determine the Number of Subnets and Hosts:
The subnet mask `255.255.255.224` has 27 bits set to 1 (8+8+8+3), which means there are 5 bits for host addresses (32 – 27 = 5). This allows for 2^5 = 32 addresses per subnet, including the network and broadcast addresses.
- Find Subnet Ranges:
Subnet 1: `192.168.1.0` to `192.168.1.31`
Subnet 2: `192.168.1.32` to `192.168.1.63`
Subnet 3: `192.168.1.64` to `192.168.1.95`
Subnet 4: `192.168.1.96` to `192.168.1.127`
- Determine Valid Host IPs:
Option 1: `192.168.1.45`
Option 2: `192.168.1.63`
Option 3: `192.168.1.95`
Option 4: `192.168.1.128`
- Convert these addresses into binary to compare:
Subnet mask in binary: `11111111.11111111.11111111.11100000`
IP addresses in binary:
- 168.1.45`: `11000000.10101000.00000001.00101101
- 168.1.63`: `11000000.10101000.00000001.00111111
- 168.1.95`: `11000000.10101000.00000001.01111111
- 168.1.128`: `11000000.10101000.00000001.10000000
- Determine Valid Hosts:
- 168.1.45: Within Subnet 1, not a broadcast or network address, so valid.
- 168.1.63: Broadcast address for Subnet 2, not valid for hosts.
- 168.1.95: Broadcast address for Subnet 3, not valid for hosts.
- 168.1.128: Network address for Subnet 5 (out of range), not valid.
Therefore, the valid host IP address is `192.168.1.45`.
Here’s a visual representation of the subnetting:
Pros and Cons of Subnetting
Subnetting offers several advantages, mostly in the aspect of better organization and efficiency of the network. Dividing a huge network into smaller, manageable subnets facilitates the work of network administrators by improving performance and security within the network. Smaller subnets reduce the size of the broadcast domains, hence minimizing network congestion and increasing the overall speed of operation. This also aids in undertaking efficient IP address management for better utilization of the available address space. This makes the implementation of security policies and management of network traffic much easier because different departments or functions can be isolated into separate subnets, thereby enhancing both performance and security.
However, subnetting also has some disadvantages. This is because subnetting can be complex and involves some administrative overhead, especially when dealing with large networks comprising many subnets. Poor configuration may lead to connectivity issues and gross wastage of IP addresses. Besides that, subnetting requires a lot of planning and administration so as not to run into a lot of problems involving overlapping IP ranges or routing complications. Because of this added layer of complexity, troubleshooting may well be harder and require advanced knowledge of networks and more capable tools to manage effectively. While it’s a strong tool for managing and optimizing the network, subnetting demands prudent implementation with perpetual maintenance to avoid its possible negative side.