Chapter 1

IP Addressing

By Nikhila Sattala
12 mins Read
An IP (Internet Protocol) address is a unique numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
Introduction

Before we dive into the ocean of networking knowledge, let us try to understand a basic building block of networking known as "IP address".

In the world of networking, IP address shares similarities with a postal address in the physical world. Just as a postal address helps identify the location of a physical building in the real world, an IP address serves a similar purpose in the digital world of networking.

So we can say, IP address is like a unique identifier for a device (computer, smartphone, server) on a network. It helps data packets find their way to the correct destination on the internet or within a local network, same like a post card will be delivered correctly to its destination based on its destination.
Now we got a brief idea that IP addresses are used to uniquely identify and locate devices on a network, such as computers, servers, routers, and smartphones.

And they are used to determine the path that should be taken by data packets from source to destination.

IP address in binary format

IP Address
(more specifically IPv4 address):

In technical terms, IPv4 address is a 32-bit binary number where each 8 bits are separated by a dot.
And this group of 8 bits is called as an Octet. So each IP address has four octets.

The IPv4 address we get if all the 32-bits are set to "0" is 0.0.0.0 and the IPv4 address we get if all the 32-bits are set to "1" is 255.255.255.255.
Both of them are having their own signification in networking, which we shall learn in coming sections.
By now you might be wondering that there are millions and millions of devices - computers, smart phones, routers, switches etc., connected to internet, then do we have enough IP addresses to assign to all these devices.

Well, fear not! This is where IPv6, Public IPs, Private IPs, and the fascinating concept of Network Address Translation (NAT) step in.
IPv6 Address:

IPv6 provides a significantly larger pool of IP addresses compared to IPv4, which helps accommodate the increasing number of internet-connected devices.

Format:
IPv6 addresses have a distinct format compared to IPv4 addresses. These addresses are 128 bits long, divided into group of 16-bit binary number. There are 8 such groups each separated by a colon.

And each 16-bit binary number is converted to 4 digits hexadecimal notation and represented in the IPv6 address.

Example:
Here's a valid IPv6 address:
2001:0db8:85a3:0000:0000:8a2e:0370:7334

To make IPv6 addresses more concise, double colon "::" is used to represent consecutive groups of zeros as follows:

2001:0db8:85a3::8a2e:0370:7334
Activity #1: Exploring IPv4 and IPv6 Addresses
In this assignment, you will explore the world of IP addressing by observing and comparing both IPv4 and IPv6 addresses assigned to your devices.
You will find out the IPv4 and IPv6 addresses assigned to your computer and mobile device.

Instructions:

Step 1: Check IPv4 Address
  • Connect your computer to Wi-Fi.
  • Open Google Chrome.
  • Type "my ip" in the search bar.
  • Note the IPv4 address displayed; it's IPv4 address assigned to your computer by your ISP.
Step 2: Enable Hotspot
  • Activate mobile data or hotspot on your device.
  • Create a Wi-Fi hotspot.
Step 3: Connect Computer
  • On your computer, connect to your mobile device's hotspot.
Step 4: Check IPv6 Address
  • In Google Chrome, type "my ip."
  • Note the IPv6 address displayed; it's IPv6 address assigned to your mobile phone.
Public IP Addresses:

Public IP addresses are globally unique addresses that are used to identify devices on the internet.
These addresses can be accessed from anywhere in the internet, making them suitable for web servers, email servers, and other services that need to be reachable by external users

Example #1 - Google's Public IP

To illustrate with an example, when I "ping google.com" from my Linux machine, in response I could see an IP address:

$ ping google.com
PING google.com (142.250.182.110) 56(84) bytes of data.
64 bytes from maa05s21-in-f14.1e100.net (142.250.182.110): icmp_seq=1 ttl=59 time=17.1 ms
64 bytes from maa05s21-in-f14.1e100.net (142.250.182.110): icmp_seq=2 ttl=59 time=16.6 ms
64 bytes from maa05s21-in-f14.1e100.net (142.250.182.110): icmp_seq=3 ttl=59 time=16.6 ms

This IP address - 142.250.182.110 is the Public IP assigned to Google's internet facing server.

If you enter https://142.250.182.110 in your browser, this will return Google page.
It shows that this Public IP is accessible from anywhere in the internet.

Example #2 - Your Computer's Public IP
If your personal computer is connected to internet, it means that your computer is also accessible from anywhere in the internet through Public IP.

But how to check the public IP assigned to your computer.
We can use "curl ident.me" command in your linux terminal as follows to know your public IP:
$ curl ident.me
49.205.242.XXX

49.205.242.XXX is Public IP assigned to my computer.

Our Internet Service Providers (ISPs) assign public IP addresses to our computers.
These addresses are typically leased or dynamically allocated by ISPs and can change over time.
So, Public IP addresses enable devices to send and receive data across the global network (i.e, internet).
Private IP Addresses:

In real time applications, not all devices need to be directly accessible from the internet.
Consider servers like databases; we often prefer to keep them tucked away from public view. That's where private IP addresses come into play.

For such devices we assign Private IP addresses so that they are accessible only from the devices that are in the same network but not accessible from devices that are outside that private network.

Private IP addresses are typically assigned from reserved address ranges defined by the Internet Assigned Numbers Authority (IANA). The most commonly used private IP address ranges are:

  • 10.0.0.0 to 10.255.255.255,
  • 172.16.0.0 to 172.31.255.255, and
  • 192.168.0.0 to 192.168.255.255.
So, when it comes to safeguarding certain devices from the broader internet, private IP addresses comes into play.
Ethernet Interfaces

Before practically assigning IP addresses to a host machine, we need to understand another basic concept of networking known as Ethernet interface. You might have studied about Ethernet interfaces in our Computer Fundamentals course, just to recap:

Ethernet interfaces, commonly found on computers and network devices, serve as the bridge that connects your device to a local network or the internet.

Each interface has a unique MAC (Media Access Control) address, which serves as its hardware identifier on the network.

These interfaces enable the transmission of data packets between your device and other devices within the same network, allowing for communication and data exchange.

Ethernet interfaces come in various forms, such as wired (Ethernet cables) and wireless (Wi-Fi) connections. You can view all the Ethernet interfaces that are available on your machine using the following command:

$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether cc:6b:1e:83:31:e5 brd ff:ff:ff:ff:ff:ff altname wlp1s0
3: enx00e04cb7f5c0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 00:e0:4c:b7:f5:c0 brd ff:ff:ff:ff:ff:ff
In the above example, you could see:
  • An Ethernet interface named "enx00e04cb7f5c0".
No worries, if you don't find this kind of Ethernet interface in your machine.
This Ethernet interface comes into picture only after connecting an Ethernet cable to your computer's Ethernet port.

  • "wlo1" - Wireless Ethernet Interface
These interfaces enable devices to connect to Wi-Fi networks.

  • "lo" - loopback interface is a special kind of interface which is explained below.
Loopback Interface
The loopback interface, often referred to as "localhost" or "lo," is a special network interface on a computer. This interface is assigned a specific IP address, which is usually "127.0.0.1" in IPv4 and "::1" in IPv6.

Let us better understand about it through an example:

Let's say you're a software developer working on a web application. You want to test the application's functionality, but you don't want to deploy it on a live external server.

Here you can test your web application in your local machine (i.e, in your computer itself). For that, your web application needs to be configured to use loopback interface IP - 127.0.0.1 instead of your external server's IP.
Then web applications runs in your local machine, without the need for an external network connection to your remote web server.

Assigning a Private IPv4 address

From the output of "ip link show" command in my computer, I could see that we have Ethernet interface but no IPv4 or IPv6 address assigned to it.

$ ip link show
3: enx00e04cb7f5c0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:e0:4c:b7:f5:c0 brd ff:ff:ff:ff:ff:ff

But from the above theory we understood that for a device to communicate with other devices it has to possess an IP address.

So we need to assign an IP address to an interface.

This can be done either manually or dynamically through a protocol called Dynamic Host Configuration Protocol (DHCP), about which we will learn in later sections of the course.
Activity #2: Assigning a Private IPv4 Address Manually in Ubuntu
In this assignment, you will understand how an IP address can be assigned to an Ethernet interface in Ubuntu machine.

Prerequisite:

  1. You need an Ethernet cable.
  2. Connect the Ethernet cable one end to your computer's Ethernet port and other end to your friend's computer's Ethernet port or to a router.

Instructions:

Step 1: Access Network Settings
  1. Click on the network icon in the system tray.
  2. Select "Wired Settings" or "Wi-Fi Settings," depending on your connection type.

Step 2: Choose Ethernet Interface
  1. In the settings window, select your Ethernet interface. It's typically labeled as "Ethernet" or "Wired Connection."

Step 3: Configure IPv4 Settings
  1. Click on the "IPv4" tab.
  2. Choose "Manual" from the dropdown menu.
  3. Click the "Add" button to add a new IP address.
  4. Enter the desired private IP address, subnet mask, and gateway address.
IP address as - 192.168.0.1
subnet mask as - 255.255.255.0
Gateway address as - 192.168.0.1

  1. Optionally, you can set DNS servers if required.
  2. Click "Apply" to save your settings.
Assigning a Public IPv4 address

Now that you are able to assign a private IPv4 address to your computer, let us understand further, how to assign a public IP to your computer.

Here, you know that if any device has a public IP assigned to it, it is accessible from anywhere in this world of internet. It means you are connected to internet through public IP.

Also you are ware that Public IPs are assigned by your Internet Service Provider (ISP).
But suppose, if there are 100 computers in your office then will your office ISP provide 100 Public IPs to your office ?

Absolutely not ! Here comes a technology called Network Address Translation (NAT) using which all the computers in your office get internet access even though your service provider gives you only one Public IP.

Let us explore NAT in the coming sections of the course.
Summary
In summary, private IP addresses are used for internal communication within private networks and are not accessible from the public internet.

Public IP addresses, on the other hand, are globally unique and routable on the internet, allowing devices to communicate with each other across the world.