Introduction to IP Addressing

Introduction to IP Addressing

A computer network is a connection of two or more computer systems connected through a wired or wireless medium. Data needs to be transferred from one place to another in a computer network. How does the data sent by one system get correctly delivered to the expected target?
The IP address is the answer to it all. IP addresses are used to uniquely distinguish any device in a network.

WHAT ARE IPv4 and IPv6 ADDRESS?

IPv4 address

IPv4 has a length of 32-bits thus making approx. 4.3 billion unique IP addresses. This might seem to be a really big number, but in reality, there are a lot of devices that are connected to the internet ranging from mobile phones and laptops to cars and smart house systems. Moreover, IPv4 is known to waste a lot of available IP addresses. to overcome the shortage of IPv4 addresses, 2 methods are introduced

  • IPv6 addresses

  • Network Address Translation

IPv6 has a length of 128-bits and gives approx. 3.4 x 10³⁸ addresses. Also, IPv6 uses hexadecimal digits unlike decimal in the case of IPv4. e.g., fe80:cb0c:4d4b:6295:c3c1. But for this article let’s concentrate on IPv4.

CLASSIFICATIONS OF IP ADDRESSES

  1. Static and Dynamic addresses

As the name suggests, the address is fixed in the case of static addresses and changes in a periodic fashion in the case of dynamic addresses. Static IP addresses are important for services that need to be located on the internet, such as web servers. A huge amount of internet users are people looking for resources and services, thus do not require a static address, moreover, dynamic address increases privacy as the IP address of a device keeps changing, thus the information about the device or the user can’t easily be accessed by just knowing their IP address.

2. Public and Private addresses

The number of distinct IP addresses is fixed and we are running short of them. To solve this problem, we use the concept of public and private IP addresses. Each device connected to a network (e.g. home network) is referred using a unique IP address inside the network. But outside the network, the IP address of the router is used to refer to every device in the network.

NETWORK ADDRESS TRANSLATION (NAT)

Each device in a network has a unique private address inside the LAN network and the router of the LAN network has a private as well as public address.

When a device inside the network makes a web request to a server or any other device present on the internet, the request is sent from the device to the network router using the private IP address, but when the request goes out of the LAN network, it is translated into the public address of the router.

Consider the below network, there is a LAN with 1 switch (192.168.1.1) to which 3 computers with the IP addresses 192.168.1.3, 192.168.1.4 and 192.168.1.5 respectively are connected. When computer 1, with private IP address 192.168.1.3, makes a web request to a server (85.202.9.3), the source is the private address of the computer and the destination is the IP address of the server respectively. But when the request leaves the network, the private IP address is translated to the public IP address of the router.

It is observed that the 3 computers share the same IP address, thus reducing the number of public IP addresses needed. Another advantage is that, if the web request is being eavesdropped by someone outside the network, the hacker can only find the IP address of the router and not the computer, thus it increases the privacy of users.

example for private and public IP address

PORTIONS OF AN IPv4 ADDRESS

An IPv4 address has 2 components, the network address and the host address. The network address is used to find the network in which the device is located and the host address is used to find the device in the network.

portions of IPv4 addresses

IPv4 CLASSES

IPv4 is divided into 5 classes depending on the number of devices in the network. The first octet represents which class a given IP address belongs to.

Class A

  • Large networks

  • The first octet represents the network portion

  • The first bit is always 0, thus the first octet can range from 1 (00000001) to 126 (01111110)

  • It is to be noted that the value 127 (01111111) is used for loopback.

  • Number of network addresses = 2⁷— 2 = 126

  • Number of host addresses = 2²⁴— 2 = 1,67,77,214

Class B

  • Medium networks

  • The first and second octet represents the network portion.

  • The first bit is always 0 and the second bit is always 1.

  • The first octet ranges from 128(10000000) to 191(10111111) and the second from 0 to 255.

  • Number of network addresses = 2¹⁴= 16,384

  • Number of host addresses = 2¹⁶— 2 = 65,534

Class C

  • Small networks

  • Used in the case of home networks

  • The first, Second and Third octet represents the network portion.

  • The first three bits are always 110.

  • The first octet ranges from 192(11000000) to 223(11011111) and the second and third from 0 to 255

  • Number of network addresses = 2²¹= 20,97,152

  • Number of host addresses = 2⁸— 2 = 254

Class D

  • Used for multicasting

  • The first four bits are always 1110.

  • The first octet ranges from 224 (11100000) to 239(11101111).

  • The concept of network and host portion does not exist in multicasting.

Class E

  • Experimental class

  • The first four bits are always 1111.

  • The first octet ranges from 240 (11110000) to 255(11111111).

  • Class E doesn’t have the concept of network and host address.

IPv4 classes

SUBNETTING

A subnet can be defined as a network inside a network. Subnets make the network more efficient as it reduces the number of devices from the source to the destination.

WHAT ARE HOST, SUBNET MASK AND BROADCAST ADDRESS?

The host address is the address assigned to the main network device, generally the router. The host address has its host portion filled with 0’s.

The subnet mask is the IP address with the first n bits filled with 1’s and the remaining bits filled with 0’s. It is used to specify the number of bits present in the network portion (equal to n).

The broadcast address is the address used to broadcast data to every node on the network. The broadcast address has its host portion filled with 1's.

WHY DO WE NEED SUBNETTING

Broadcasting is a problem that comes with not using the concept of subnetting. The request sent from a computer to the internet is forwarded to all the computers in the network. This is a security risk.

Example to understand the above termsConsider a network (class C) with the below devices
 1. switch/router (192.168.1.0)
 2. computer 1 (192.168.1.1)
 3. computer 2 (192.168.1.2)The host address is the IP address of the network with the host portion filled with all 0’s. i.e., 192.168.1.0. The subnet mask is 1’s filled in the network portion and 0’s filled in the host portion. i.e., 255.255.255.0. The broadcast address is filled with 1’s in the host portion. i.e., 192.168.1.255In the above example, when computer 1 makes a web request, the request is sent to a switch/router and then forwarded to all the nodes connected to that device. i.e., computer 2 also gets the information about the request made by computer 1.

CLASSLESS INTER-DOMAIN ROUTING

Classless inter-domain routing (CIDR) is a network concept designed to oversee the assignment of IP addresses to a system to replace the outdated classful addressing system. Using the CIDR method, there is low wastage of IP addresses.

Let us understand CIDR with an example. Consider the IPv4 address 192.168.200.10/28. The /28 represents the number of bits present in the network portion.

Write the IP address in binary form 11000000.10101000.11001000.00001010 . The first 28 bits are the network portion and the last 4 bits are the host portion. The subnet mask has its first 28 bits as 1’s and the remaining 4 bits as 0’s. i.e., 11111111.1111111.1111111.11110000 or 255.255.255.240. The host address has its host portion filled with 0’s. i.e., 11000000.10101000.11001000.00000000 or 192.168.200.0. The number of hosts is 2⁴ = 16

RESOURCES

  1. IP addressing zero to hero — udemy.com

  2. what are network id and host id in IP addresses — geeks for geeks article

  3. IP addressing — medium.com

  4. what is an IP address and what is your IP address — networkworld.com

  5. IPv4 address classes — tutorialspoint.com

  6. what is a subnet - cloudflare.com

  7. CIDR address and subnet masking on IP networks part 1 — medium.com

  8. CIDR address and subnet masking on IP networks part 2— medium.com

#WeMakeDevs