Chapter 2

CIDR, Networks and Subnets

By Nikhila Sattala
15 mins read

In the world of networking, there used to be two main approaches: classful and classless. Initially, the internet relied on Classful networks, which divided IP addresses into three classes: A, B, and C. However, this system didn't distribute addresses efficiently. To accommodate the internet's rapid growth, a more flexible method called Classless Inter-Domain Routing (CIDR) was introduced. Unlike classful networks, CIDR doesn't rely on predefined classes and allows for a more efficient allocation of IP addresses.


In this training, we'll delve into CIDR networks, hosts, and subnet masks.
Introduction

In our previous discussion, we delved into the world of IP addresses, the numerical labels that uniquely identify devices on a network.


However, IP addresses alone are not sufficient to make devices communicate with each other.

It requires, Networks to facilitate communication between the devices, to allow data to flow seamlessly from one point to another, whether it's across the room or around the globe.

This chapter explores the broader realm of networking, taking us beyond IP addresses and into the essential concepts of networks, subnets, and CIDR (Classless Inter-Domain Routing) - a powerful tool that streamlines IP address management.

In this journey, we will uncover the inner workings of networks, learn how to efficiently organise, configure and manage networks for hosting a web application on a cloud infrastructure.

By the end of this chapter, you will have a solid foundation in the critical networking concepts, empowering you to design, troubleshoot, and optimise networks of a web app effectively.
A network is a structured and interconnected system of devices, such as computers, servers, routers, switches, and various communication hardware, that are linked together to enable data exchange and communication.

They play a crucial role in modern computing and communication, serving as the infrastructure that allows devices and users to communicate and share data efficiently.
Representation of Networks

Before designing networks for a web app, we first need to understand how networks are represented and their standard notation.

In the world of networking, we often use a system called CIDR (Classless Inter-Domain Routing) to represent networks in a straightforward way.

CIDR lets us specify the size of a network right in the IP address itself.

Here's how it works: An IP address is made up of 32 bits (ones and zeros), but we can choose how many of these bits represent the network part and how many represent individual devices. We do this by adding a "slash" followed by a number to the IP address. For example, 192.168.0.0/21 means that the first 21 bits are for the network, and the rest are for devices.
  • In binary, the IP 192.0.1.20 looks like 11000000.00000000.00000001.00010100.
  • The 24 bits in green shows the Network portion of an IP address. No modification can be done to this network portion of the address.
  • The remaining 8 bits in black are available for host assignment on the network. We shall discuss about this allocation of IP addresses to hosts, further in coming sections.

So from the above explanation we can understand that, if there are 10 computers with their IP addresses as 192.0.1.1/24, 192.0.1.2/24, 192.0.1.3/24, 192.0.1.4/24,.......192.0.1.10/24, then we can say that all these computers are part of same network 192.0.1.0/24.
Public and Private Networks
In our previous discussion, we delved into the world of IP addresses, the numerical labels that uniquely identify devices on a network.

However, IP addresses alone are not sufficient to make devices communicate with each other.

It requires, Networks to facilitate communication between the devices, to allow data to flow seamlessly from one point to another, whether it's across the room or around the globe.

This chapter explores the broader realm of networking, taking us beyond IP addresses and into the essential concepts of networks, subnets, and CIDR (Classless Inter-Domain Routing) - a powerful tool that streamlines IP address management.

In this journey, we will uncover the inner workings of networks, learn how to efficiently organise, configure and manage networks for hosting a web application on a cloud infrastructure.

By the end of this chapter, you will have a solid foundation in the critical networking concepts, empowering you to design, troubleshoot, and optimise networks of a web app effectively.

When it comes to hosting a web application, your network infrastructure plays a pivotal role in ensuring accessibility, security, and performance. Two fundamental types of networks come into play: public networks and private networks.
NOTE: Let us consider this picture as a first reference for the infrastructure setup that we will be configuring in a physical datacenter or in a cloud environment for a web application.
As we delve deeper into this training module, we shall see how this setup will evolve with all the required components to run a web app.
Public Networks
These networks are designed to be accessible from the broader internet. They serve as the gateway through which users from around the world can reach your web application. Here's what you need to know:

  • Public IP Addresses: Servers and devices on a public network typically have public IP addresses. These addresses are globally unique and can be reached over the internet.

  • Web-Facing Servers: In your network architecture, web-facing servers, such as web servers, mail servers, file servers and load balancers, reside in the public network. These servers directly interact with internet users and serve web content.

  • Security Measures: While public networks are accessible, they also require robust security measures. Firewalls, intrusion detection systems, and encryption are often used to protect these servers from unauthorized access and cyber threats.
Private Networks
Private networks, on the other hand, are secluded from the public internet and provide a controlled environment for your web application's internal workings. Here's what you should know:

  • Private IP Addresses: Devices within a private network typically use private IP addresses. These addresses are not directly reachable from the internet, enhancing security.

  • Backend Infrastructure: Backend application servers, database servers, and other sensitive components of your web application are placed in the private network. This isolation safeguards critical data and resources from external threats.

  • Communication within the Network: The private network facilitates secure communication between backend servers while keeping them hidden from public access. This is essential for processing and managing data without exposing it to potential risks.
Connecting Public and Private Networks

From the above picture, we understood that the servers that needs internet access are configured in Public network and those which needs to be secured without getting exposed to the internet are configured in Private network.

But have you ever wondered how devices in one single network communicate with each other and how they communicate with the devices that are present in different network.

To be more precise,
  • how "Application Server" is communicating with "Database" where both are in same Private network-192.0.2.0/24 and
  • how "Web server" in Public network is communicating with "Application server "in Private network.

Here comes the core networking concepts Layer-2 Switching and Lyaer-3 Routing, which are explained in detail in the next section.

By understanding Layer-2 Switching and Layer-3 Routing, you'll gain insight into how data flows within and between networks, enabling you to design and configure a network that ensures seamless communication for your web applications. Let's explore these networking fundamentals in depth!