We need to have the basic knowledge of Networking concepts like IP Addresses, Subnets, and CIDR Notation before working on any Cloud infrastructure. Here I am giving the basic to my knowledge on a few important concepts like CIDR notation, Subnet Mask, Subnetting which will be useful for any cloud vendors

## What is IP Address

- IP addresses are nothing but 32 bits long– IPv4– and these are four octets of 8 bits each

Example11111111.1111111.11111111.11111111 Which is read in decimal form as 255.255.255.255

- An IP address is interpreted as composed of two parts: a network-identifying prefix followed by a host identifier within that network.
- IP address consists of two groups of bits in the address: the most significant bits are the network prefix, which identifies a whole network or subnet, and the least significant set forms the host identifier, which specifies a particular interface of a host on that network. This division is used as the basis of traffic routing between IP networks and for address allocation policies.
- Earlier address was considered to be the combination of an 8, 16, or 24-bit network prefix along with a 24, 16, or 8-bit host identifier respectively. And this was called Class-full Network routing
- Class A networks, which all 8 bits– the first octet being all 1’s. Class B network which is the first two octets being all 1’s, and class C network which is the first three octets all 1’s.
- Before moving further ,lets find out how to convert IP address from binary to decimal and decimal to binary

## Binary to Decimal conversion and Vice Versa

### Binary to Number conversion

Let’s take an example where all the 32 bits are 1

11111111.1111111.11111111. 11111111

We can convert to Number for each octet using the formula given below

2^{7}x 1 + 2^{6}x1 + 2^{5}x 1 + 2^{4}x1 + 2^{3}X 1 + 2^{2}x1 + 2^{1}x 1 + 2^{0}x 1=128 + 64 + 32 + 16 + 8 + 4 +2 +1=255

So each bit is multiplied by the power of 2 corresponding to their position

So, calculating the same way, we get

255.255.255.255

**Another example**

11000000 – 10101000 – 00000000 – 00000101

*First Octet*

11000000

=2^{7}x 1 + 2^{6}x1 + 2^{5}x 0 + 2^{4}x0 + 2^{3}X 0 + 2^{2}x0 + 2^{1}x 0 + 2^{0}x 0

=128 + 64= 192

*Second Octet*

10101000 =2^{7}x 1 + 2^{6}x0 + 2^{5}x 1 + 2^{4}x0 + 2^{3}X 1 + 2^{2}x0 + 2^{1}x 0 + 2^{0}x 0=128 + 32 + 8= 168

*Third Octet*

00000000 =2^{7}x 0 + 2^{6}x0 + 2^{5}x 0 + 2^{4}x0 + 2^{3}X 0 + 2^{2}x0 + 2^{1}x 0 + 2^{0}x 0=0

*Fourth Octet*

00000101 =2^{7}x 0 + 2^{6}x0 + 2^{5}x 0 + 2^{4}x0 + 2^{3}X 0 + 2^{2}x1 + 2^{1}x 0 + 2^{0}x 1=4 + 1 =5

So, the Decimal IP address is 192.168.0.5

**Binary to Decimal Conversion**

1. We can get the binary numbers by continually divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero.

2. Then we write the remainder from bottom

3. If the count of the remainder is less than 8 , we add the zero to the left of the binary number

**Example****192.168.0.5**

*First, take for 192*

So, the Binary number is 11000000

*Now take for 168*

So, 10101000

*Now take 0*

this will be 0 only So, we can write 00000000

*Now take 5*

So, binary is 101

Now since the count is less than 8, we can add zero padding at the left end

00000101

So Binary equivalent is**11000000 – 10101000 – 00000000 – 00000101**

## What is Subnet mask or netmask?

- A subnet mask separates the IP address into the network and host addresses. The whole idea of network and host is actually done using subnet masks.
- Subnet mask is made by setting network bits to all 1’s and setting the host bits to all 0’s
- It uses the same format as an IPv4 address — four sections of one to three numbers, separated by dots

**Example**

192.168.0.5

If this is a class C address and 24 bit is the network address, then subnet mask will be

11111111.11111111.11111111.00000000

Converting to Decimals

255.255.255.0

So, this is the subnet mask for this IP address

## Classless Inter-Domain Routing ( CIDR)

- Earlier Classful network design has some flaws like wastage of IP addresses, Classless Inter-Domain Routing ( CIDR) was introduced to resolved it.
- Classless Inter-Domain is a method for allocating IP addresses and IP routing
- Unlike classful network design where network prefix as one or more 8-bit groups, resulting in the blocks of Class A, B, or C addresses, CIDR address allows any address-bit boundary
- it introduced a new method of representation for IP addresses known as
**CIDR notation**, in which an address or routing prefix is written with a suffix indicating the number of bits of the prefix, such as 192.168.0.5/24 or 192.168.0.5/26 - So, in first 24 bit are for Network and in second 26 bit is for the Network. We can convert this to subnet also

(1) 192.168.0.5/24 Subnet Mask will be 11111111.11111111.11111111.00000000 Converting to Decimals 255.255.255.0 (2) 192.168.0.5/26 11111111.11111111.11111111.11000000 Converting to Decimals 255.255.255.192

If we need to tell the network prefix of this address, we can use the below method

Let’s understood with the example 192.168.0.5/26 (1) Convert the IP into binary format 11000000 - 10101000 - 00000000 - 00000101 (2) Write the 1’s bit below as given for the network 11111111.11111111.11111111.11000000 (3) Write them together as below 11000000 - 10101000 - 00000000 - 00000101 11111111 – 11111111 - 11111111 - 10000000 (3) Do logical add on above and below for each bit 1100000-10101000-00000000-00000000 Which can be written in decimal As 192.168.0.0 So, this is network prefix

## Subnetting

- Subnetting is the process of dividing large network into smaller network.
- Basically, it is designating some high-order bits from the host part as part of the network prefix and adjusting the subnet mask appropriately

For the network 192.168.0.0/24, the last eight-bit is used for the host. So total number of host possible is

28 = 256.

We can divide this network into many subnets

The number of networks formed depends on the bit taken

- If 1 bit is taken . Two networks are formed as that bit can be 0 or 1 i.e. 2
- If 2 bits are taken , four networks are formed, as 01,10,11,00 is the possible combination
- If 3 bit are taken , 8 network are formed, as 001,100,111,000,101,010,110,011 is the possible combination

Hosts in each will be defined by the number of bits remaining for the Host portion

- So, for 25-bit, host will be 2^7 = 12
- So, for 26-bit, host will be 2^6 = 64
- So, for 27-bit, host will be 2^5 = 32

The network Prefix for each of these networks can be

- If 1 bit is taken . Two networks are formed as that bit can be 0 or 1 i.e. 2. Network Prefix will be 192.168.0.0 and 192.168.0.128
- If 2 bits are taken , four networks are formed, as 01,10,11,00 is the possible combination,Network Prefix will be 192.168.0.0 ,192.168.0.64, 192.168.0.128, and 192.168.0.192
- If 3 bit are taken , 8 network are formed, as 001,100,111,000,101,010,110,011 is the possible combination,Network Prefix will be 192.168.0.0 ,192.168.0.32, 192.168.0.64, 192.168.0.96,192.168.0.128,192.168.0.160, 192.168.0.192 and 192.168.0.224

I hope you find this information on IP Addresses, Subnets, and CIDR Notation. This is going to help when working with Oracle Cloud Infrastructure

**Related Articles**

oracle cloud infrastructure : Oracle Infrastructure as a Service is called Oracle Cloud Infrastructure (OCI).It offers storage,compute,database, networking, edge services

OCI block storage: OCI Block storage is the NVMe SSD-based storage that you can attach to any compute instance that was launched. Check out about backup, cloning

Local NVMe storage in OCI :Local NVMe storage is a SSD based temporary storage. Check out details about Local NVMe storage in OCI and how to use it in Oracle cloud

Virtualization : Virtualization is the process of creating multiple virtual machines /operating system from one physical hardware box with the help of a hypervisor

what is cloud computing: Learn about what is cloud computing and how it can benefit the organization. Various cloud models, cloud vendors, cloud examples

iaas paas saas : Learn about Cloud Computing Basics: iaas paas saas with offerings

https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

## Recommended Courses

Cloud Computing Concepts : it Covers Fundamentals of Cloud Computing and types of cloud-like private, public, hybrid, IAAS, SAAS, PAAS, and cloud platforms like AWS, Azure, and Google Cloud. One of must-have course for anybody starting with Cloud

Introduction to Cloud Computing on Amazon AWS for Beginners : Learn about Amazon Web services.Various offerings are available with it like EC2, EBS ,S3. A good course for anybody starting with AWS

Google Cloud Platform (GCP) Fundamentals for Beginners : Learn how to use GCP compute, storage, and networking services, Key services of Google Cloud Platform.A good course for anybody starting with GCP

Introduction to Cloud Security with Microsoft Azure : It covers Azure services, Azure PowerShell. A good course for anybody starting with Microsoft Azure

## Leave a Reply