Networking Refresher: IP, CIDR, Subnetting
Revise the fundamental networking concepts like IP, CIDR, and subnetting.
Building resilient and secure infrastructures and workloads requires a fundamental understanding of networking. In the context of the cloud, we don’t have to manage our own physical hardware, but the task of configuring the virtual resources to meet our requirements and operate effectively lies with us.
Keeping this in perspective, let's familiarize ourselves with the basics of the Internet Protocol used by AWS services to communicate with each other.
Internet Protocol
Internet Protocol outlines the set of rules for addressing and routing data on the internet. It enables communication between two host machines over a network. Every host machine or device on the internet is assigned a unique identifier, namely an IP address. The Internet Protocol delivers the packets over the network using these unique identifiers. Once delivered, the transport layer protocols take over further processing the packets and handing them over to the respective applications.
The Internet Protocol addresses come in two flavors:
IPv4
IPv6
IPv4
Internet Protocol version 4, or IPv4, is a 32-bit addressing scheme where each IP address is denoted by four octets separated by dots, for example: 10.0.0.0
. Each octet in the IP address represents 8 bits, which means that the value can range from 0
to 255
. Similarly, since IPv4 supports 32 bits, we can have
IPv6
To deal with the limited number of addresses in IPv4, Internet Protocol version 6 or IPv6 supports 128-bit addresses, which are represented by a hexadecimal notation. Each IPv6 address has eight 16-bit sections, each separated by a colon, for example: d14c:1368:3e4a:0c9f:fcf5:460c:e7dd:3205
. With 128 bits, we can uniquely identify
IPv6 comes with other protocol enhancements, such as better security and privacy, but for the sake of simplicity, we have only covered the address space enhancement.
IPv4 is still the most commonly adopted version, so we will focus on IPv4 addressing for the rest of the lesson.
Classful IPv4 addressing
The IPv4 addresses can be divided into two parts:
Network: The network address corresponds to the number of bits used to uniquely identify a network.
Host: The host address represents the unique identifier of a device/host on that network.
In the traditional context, the IP addresses were divided into smaller groups/classes via classful addressing. Each class uses different bits to represent the network and host addresses. The three primary classes available for general use are A, B, and C:
Class A: This class uses the first octet (8 bits) as the network address and the remaining octets for host addresses. The first bit from the network address is always 0 so we can’t use it. Therefore, the remaining 7 bits make
networks. The 24 bits from the host part make hosts in each network. For example, let’s consider 20.0.0.1
address where20
represents the network address, and the0.0.1
is the host address.Class B: This class uses the first two octets (16 bits) for the network and the remaining octets for host addresses. In Class B, the first bits from the network bits are always 10, which makes the network space of
addresses. There are hosts in each network. For example, let's consider 131.17.0.3
, where131.17
represents the network address, and the0.3
is the host address.Class C: This class uses the first three octets (24 bits) for the network and the last octet for host addresses. The first three network bits are fixed to 110 and the remaining 21 bits make
networks in this class with hosts in each network. For example, let’s consider 200.168.1.19
, where200.168.1
represents the network address, and the19
is the host address.
Note: The first and the last address in each class are reserved as host identifier/address and broadcast address, respectively and can not be used.
The classes can be summarized in the table below:
Classful Addressing
Network Class | IP Range | Network Bits | Host Bits |
Class A |
| 8 | 24 |
Class B |
| 16 | 16 |
Class C |
| 24 | 8 |
Apart from the above classes, we have class D and E networks, which are inaccessible for general use. While classful addressing is useful in organizing the IP addresses, it comes with limitations as well:
Inefficient IP allocation: Each class has a fixed number of hosts in the classful addressing system, which can be wasteful in many instances. For example, an organization with 300-350 devices would have to go for the class B network, which would have left the other 65,000+ IP addresses unused.
Limited network design: Similarly, the classful system wouldn’t allow combining networks as required. For example, the IP addresses
128.0.0.0
and128.1.0.0
belong to different networks of class B in the classful architecture.
To address these limitations, Classless Inter-Domain Routing (CIDR) was introduced. But, before we discuss it, let’s first review an important concept: subnet mask.
Subnet mask
In classful addressing, each class had a fixed number of network and host bits, which makes it easier to identify the class a particular IP belongs to. For example, the IP 10.0.0.1
belongs to class A, with the first octet representing the network address and the remaining octets representing the host address.
A subnet mask is an alternative binary representation of the network and host portions of the IP address. The network bits are represented by 1
's whereas the host bits are presented by 0
's. For example, the default subnet mask for IP addresses in class A would have the first 8 bits set to 1
, as the first octet in class A represents the network part, while the remaining bits would be set to 0
signifying the host part: 11111111.00000000.00000000.00000000
. A router in a network topology uses the subnet mask to determine and route the messages to the appropriate network and, subsequently, the appropriate host.
Classless Inter-Domain Routing (CIDR)
Coming back to the discussion around the limitations of classful addressing, Classless Inter-Domain Routing (CIDR) was introduced to bypass those limitations and effectively manage IP allocations. It does so with the help of the Variable Length Subnet Mask (VLSM). Instead of relying on a fixed number of bits for the network, CIDR enables using variable lengths of bits to represent the network. This helps with the underutilization of IP addresses, as mentioned above.
But how does a router, in this case, identify the appropriate network? The answer lies in the CIDR notation, which includes the IP block, followed by a slash and the number of selected network part bits.
Let’s look at a few examples to further cement our understanding:
In
x.x.x.x/24
,/24
represents the number of network bits, which means the given address block contains 28 orhosts or IP addresses. Similarly, in
x.x.x.x/20
,/20
represents the number of network bits, which means the given address block containsor hosts or IP addresses. In the edge case of
/32
network bits, there would only behost IP address. While /0
represents all theIP addresses in IPv4.
This makes the underutilization of IP addresses disappear while also enabling us to combine networks by specifying the number of network bits.
Subnetting
Subnetting enables splitting up large networks’ address spaces into smaller subnetworks, which in turn makes network routing more efficient. With the help of subnetting, messages can be delivered efficiently without having to go through several unnecessary hops/routers in the network.
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy