IP Address

IP address is nothing but an unique identifier for every device that is connected to a network which uses internet protocol for communication. 

The two major purpose of an IP address is:

  1. Identify the host
  2. To pinpoint the location of the device inside the network 

Just like a physical address of a location, an IP address helps in locating the location of a device inside the network.

IP address

Two versions of IP address:

  1. IPv4
  2. IPv6

IPv4:

The IPv4 version of the IP address consists of 4 parts separated by a dot in this format (xxx.xxx.xxx.xxx) which allows a total of 4.3 billion unique IP addresses that can be used by devices around the world connected to the internet. Though the number looks large enough to accommodate all devices in the world, it is not enough to do so when the technology grows faster and more devices get connected to the internet everyday. That is why IPv6 was invented.

Structure of IPv4 address:

  1. It contains 32 bits divided into four 8-bit octets. 
  2. It is written in decimal format (ex: 192.168.1.1)
  3. Every octane ranges from 0 to 255
  4. It is represented with a subnet mask to define network and host (ex: 192.168.8.1/24)

IPv6:

The sole purpose of IPv6 addresses is to accommodate more devices than IPv4 and also to be able to handle more devices in the future. 

The IPv6 addresses follow a 128-bit format (for example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) this combination gives you almost unlimited number of IP addresses which could also handle future spikes in number of devices connected to the internet. 


Structure of IPv6:

  1. It contains 128 bits split into eight 16-bit blocks.
  2. Unlike IPv4, it is written in colon separated hexadecimal format ( for example: 2001:0db8:0000:0042:0000:8a2e:0370:7334). 
  3. Consecutive zeros in the IPv6 addresses can be shortened by using :: once per address ( for example the same above address can also be written as 2001:db8::8a2e:370:7334).
  4. The IPv6 also includes fields for traffic class, flow labels & next header fields. These give IPv6 an advantage in managing the traffic efficiently.

Advantages of IPv6:

  1. Advanced headers: IPv4 headers are very simple and less efficient when compared to IPv6 since IPv6 has very complex headers that are optimised for speed.
  2. No NAT requirements: NAT (Network Address Translation) is not required when you use IPv6. It is used in IPv4 because of the limited availability. 
  3. Enforces Security: IPV6 has mandatory IPsec encryption which supports security.

NOTE: Both IPv4 & IPv6 use subnetting concepts to better manage the IP address usage within the networks. 

Apart from IPv4 and IPv6 separation, the IP addresses are also categorised into two different types:

  1. Public IP address
  2. Private IP address

Public IP address:

IP addresses that are assigned to the devices that directly connect to the internet are called Public IP addresses. Assigning a public IP address to a device makes it accessible from anywhere in the world. 

Private IP address:

When you have some devices that are not directly connected to the internet but inside a local network that needs an IP address you can use the local / private IP address. You can use local IP address for all devices that are connected internally and use a public IP address that connects all these devices to the internet via NAT (Network Address Translation).

Understanding IP addresses is the first step in learning networking, internet related tech & cyber security. 

History of IP address:

The history of IP addresses began long ago around the 1970s with ARPANet. The ARPANet is known as the precursor of the modern internet. 

Initially the IPv4 address was the standard in 1981 under RFC 791. As discussed earlier, the IPv4 has a limited quantity of IP addresses around 4.3 billion addresses. Later around 1998, the current IP address format IPv6 was introduced. It is offered in a 128-bit address which is an astronomical no. of unique combinations. It will take a very long time for the IPv6 addresses to be exhausted.

Just like Private & Public IP addresses there are other categories of IP addresses based on their purpose and their way of communication.

  1. Unicast
  2. Broadcast
  3. Multicast
  4. Anycast

Unicast IP address:

Unicast IP addresses are connected to a single device. When a message/data is sent to the Unicast IP address, it will reach a specific device in the network. This Unicast IP is mostly used on all point-to-point communications.

Broadcast IP address:

Data packets sent to the broadcast IP addresses will reach all the devices inside the local network. It is important to note that broadcast IP addresses are only allowed in IPv4 and not in IPv6.

Multicast IP address:

Just like the broadcast IP addressing, it will enable the devices to do a one to many communication but only to a specific group of devices and not to all the devices in the group. This kind of addressing is mostly used in applications like video streaming, gaming etc.

Anycast IP address:

It is one-to-nearest communication model of IP addressing. When a device with an anycast IP address receives the data, it will forward to all the possible destination devices near it which have the same IP address. Usually, DNS resolution & CDNs (Content delivery networks) use this concept. 

Based on the configuration, the IP address can be further classified into two other types.

  1. Static IP address
  2. Dynamic IP address

Static IP address:

Static IP address remains constant whenever you connect to the internet from a particular device and particular ISP. It is configured manually and is mostly used on servers (floater IP). You can reserve an IP and use them permanently on a particular server until you release it. You will need to pay a fee to use an IPv4 IP address.

Advantages of Static IP address:

Stability and accessibility. With a static IP address, it is easy to manage, monitor & troubleshoot.
Improved DNS support, which is crucial to set up reverse DNS for email deliverability.

Dynamic IP address:

As the name suggests, Dynamic IP addresses are assigned dynamically by a server (DHCP) Dynamic Host Configuration Protocol and it will be changed frequently to another IP. These dynamic IP changes are handled by the ISP providers for the internet users who don't require any static / fixed IP address. It is very cost efficient. 

Advantages of Dynamic IP address:

  1. No manual intervention required. IP addresses will be automatically assigned from the network.
  2. More secure. When IP addresses change dynamically, it will be difficult for hackers to target a device.
  3. Cost effective. 
  4. Effective IP address utilization. 

How are IP addresses assigned for a device?

IP addresses are usually assigned by the following four processes.

  1. Global authority 
  2. Regional and Local assignment
  3. Private Networks
  4. IPv6 Autoconfiguration

Note: Find your IP address here 

Global Authority:

The IANA (Internet Assigned Numbers Authority) is responsible for the global IP address allocation. There are other regional registries like ARIN, RIPE & APNIC. These regional registries get some blocks for addresses from the IANA. 

Regional & Local IP assignment:

These local registries get the block from IANA and further provide them to ISPs and large organisations. The ISPs who receive the IP addresses allocate these addresses to the customers. When it comes to static IPs, they are assigned manually and for dynamic IPs, they are automatically assigned using DHCP servers.

Private Networks:

IP assignment inside the local network is usually assigned manually or it can also be done via DHCP servers. There are specific IP addresses allocated particularly for the purpose of local IP address usage. (ex: 192.168.x.x) 

IPv6 Autoconfiguration:

In devices that are compatible with IPv6 can self assign IP addresses using (SLAAC) Stateless Address Autoconfiguration which is easy for deployment.


In IPv4, the IP addresses are divided into 5 different classes for different network structures. 

Class A:

Ranges from 1.0.0.0 - 126.255.255.255 are mostly used for large networks with millions of devices connected in them. 

Class B:

Ranges from 128.0.0.0 - 191.255.255.255 are used for medium range networks with lots of devices connected.

Class C:

Ranges from 192.0.0.0 - 223.255.255.255 are used in small networks with fewer devices. 

Class D: 

Ranges from 224.0.0.0 - 239.255.255.255 are specifically reserved for multicast.

Class E: 

Ranges from 240.0.0.0 - 255.255.255.255 are reserved for experimental purposes.

These classful addressing methods are not used nowadays. Today we used CIDR - Classless Inter-Domain routing methods. But understanding the old methods are always helpful for improving your foundation knowledge. 

Subnetting and CIDR:

Subnetting:

Subnetting is nothing but a way of splitting a larger network into smaller, manageable segment of networks. Subnetting helps to optimize the IP address usage and reduce the broadcast data traffic.

CIDR:

The CIDR means Classless Inter-Domain Routing. It came as a replacement for the old classful system. It uses a slash notation (example: 192.168.1.0/24) for defining the network prefixes, flexibility and efficient space utilization.

The example which I mentioned earlier (192.168.1.0/24) means the first 24 bits are for the network and the remaining 8 bits are for the host. This kind of approach is very important for subnetting in modern networks. 

Advantages of CIDR:

  1. CIDR helps in route aggregation & scalability in large networks
  2. CIDR reduces the size of routing tables and performance of the network.

NAT and PAT difference:

What is NAT?

NAT (Network Address Translation) is a concept of allowing multiple devices in a network to use a single public IP. It helps in translating local IP address to a public IP address when communicating with the internet. 

For example: You can use a NAT gateway to allow your load balancer or EC2 instances to communicate with the internet via a static public IP.

What is PAT?

PAT (Port Address Translation) is just a subtype of NAT that maps lots of private addresses to a single public IP address via unique port numbers. It is sometimes called as NAT overload.

Advantages of NAT & PAT:

These technologies help to hide internal network structures by providing a layer of security by mapping single public IP on top.
Helps to use less public IP addresses for a large number of devices.

DNS & IP addresses:

DNS:

Domain Name System is a hierarchical system that helps in translating the human readable domain name into IP addresses.

Example: from https://www.dearrouter.com to 93.184.216.34 

Routing the request from the browser URL to the correct server IP address. DNS structure usually includes four parts.

DNS Structure:

Root domain: dearrouter.com - Top level in the hierarchy
Top level domain (TLD): .com, org, .net etc. Here in the example it is .com
Second level domain: The name of the website. 
Subdomains: blog.dearrouter.com (optional) 

DNS Records:

Here are some of the DNS records

  1. A (IPv4)
  2. AAAA (IPv6)
  3. MX (For emails)
  4. CNAME (alias records)

The most important job of the DNS is to make it easy for humans to use the internet by efficiently routing the domain names to their corresponding IP addresses. 

Some common myths about IP address:

1. Can we pinpoint someone’s location via IP address?

No, we cannot pinpoint someone’s location via IP address since IP addresses are always changeable and replaceable. Though we can identify some details like City or State but it is not possible to find the address.

2. IP address must be a secret.

No, whenever you connect to any website or server, it can see & store your IP address. IP addresses are not a secret property.

3. IPv6 will replace IPv4.

No, IPv6 is designed in a way it can coexist with IPv4. Currently we have both IPv6 and IPv4 coexisting. 

4. Different servers cannot have the same IP address.

This is wrong too. It is possible for two different servers to have same IP address via the usage of NAT gateway. These devices will have different local IPs but on the internet they will have same public IP address.