What is an IP Address?
An IP address (Internet Protocol address) is a unique numerical identifier assigned to a device connected to a network that uses the Internet Protocol for communication. It serves two main purposes:
- Identification – Uniquely identifies a device on a network.
- Location – Helps in locating the device within a network or across the internet.
Types of IP Addresses
- IPv4 (Internet Protocol version 4) – A 32-bit address format (e.g.,
192.168.1.1
), supporting about 4.3 billion addresses. - IPv6 (Internet Protocol version 6) – A 128-bit address format (e.g.,
2001:0db8:85a3::8a2e:0370:7334
), designed to handle the growing number of devices on the internet.
Public vs. Private IP Addresses
- Public IP – Assigned by an Internet Service Provider (ISP) and used to communicate over the internet.
- Private IP – Used within a local network (e.g., home or office) and not routable over the internet.
Static vs. Dynamic IP Addresses
- Static IP – Manually assigned, does not change, used for servers and hosting services.
- Dynamic IP – Assigned automatically by a DHCP server and can change over time.
Public IP Addresses:
These are necessary to accesses resources (data, web pages etc) over the internet. The organization that issues public IP addresses is the Internet Assigned Numbers Authority (IANA), which is a division of the Internet Corporation for Assigned Names and Numbers (ICANN).
Public IP addresses are unique, and a single IP cannot be allocated to multiple clients. Public IP addresses quickly ran out despite being 4 billion unique ones. To tackle this problem, engineers developed Private IP addresses.
Private IP Addresses:
These are not publicly registered on the internet. Therefore, we cannot access internet using a Private IP address. A private IP address needs to be converted into a Public IP address before we can access the internet. We can either manually assign private IPs to clients on a private network OR we can use a service like Dynamic Host Configuration Protocol (DHCP) to assign private IPs to clients on a private network. The advantage of assigning Private IPs to hosts on a private network is that we can only have one Public IP serving many hosts having individual Private IPs. This removes the need of allocating each host a dedicated Public IP.
But then how the clients with private IPs can access Internet? The solution to this problem is called Network Address Translation (NAT) through which Private IPs can be translated into Public IP at the gateway device of a private network and enabling the hosts with Private IPs to access the internet. The same gateway also translates Public IPs to Private IPs for incoming messages for the hosts in its Private Network. (More on this below)
Private IP addresses are categorized into three classes (A, B, and C), each with a specific range and number of available addresses. These addresses are reserved for internal network use and are not routable on the public internet.
Private IP Address Classes
Class | Private IP Range | Default Subnet Mask | Number of Hosts |
---|---|---|---|
A | 10.0.0.0 – 10.255.255.255 | 255.0.0.0 (/8) | ~16 million |
B | 172.16.0.0 – 172.31.255.255 | 255.255.0.0 (/12) | ~1 million |
C | 192.168.0.0 – 192.168.255.255 | 255.255.255.0 (/16) | ~65,000 |
Key Points
- Class A: Used for large organizations (e.g., multinational companies, ISPs).
- Class B: Suitable for medium-sized networks (e.g., universities, enterprises).
- Class C: Common for small networks (e.g., home and small businesses).
Subnetting & How Private IPs Work with Public IPs via NAT
1. Subnetting (Subnet Mask & CIDR Notation)
Subnetting is the process of dividing a large network into smaller sub-networks (subnets) to improve efficiency and security.
Each private IP class has a default subnet mask, which determines the number of available hosts:
- Class A:
255.0.0.0
(/8
) → 16,777,214 hosts - Class B:
255.255.0.0
(/12
) → 1,048,574 hosts - Class C:
255.255.255.0
(/16
) → 65,534 hosts
However, we can subnet further using CIDR (Classless Inter-Domain Routing). For example:
192.168.1.0/24
(Subnet mask:255.255.255.0
) allows 254 usable IPs.192.168.1.0/26
(Subnet mask:255.255.255.192
) allows 62 usable IPs.
Subnetting helps in efficient IP allocation, security isolation, and network performance optimization.
2. How Private IPs Interact with Public IPs via NAT
Since private IPs are not routable on the internet, they need to be translated to a public IP to communicate outside the local network. This is done using Network Address Translation (NAT).
Types of NAT:
- Static NAT – One-to-one mapping of a private IP to a public IP.
- Dynamic NAT – Maps private IPs to a pool of public IPs dynamically.
- PAT (Port Address Translation, aka NAT Overload) – Maps multiple private IPs to a single public IP using different ports.
Example of NAT in Action:
- Device with private IP
192.168.1.10
wants to access the internet. - The router (with public IP
203.0.113.5
) translates192.168.1.10 → 203.0.113.5
using PAT. - When the response comes back, the router translates it back to
192.168.1.10
.
This is how a single public IP can serve an entire network of private IPs.
Benefits of Using Private IPs & NAT
✅ Security – Private IPs are not exposed to the internet, reducing attack risks.
✅ Efficient IP Usage – IPv4 has limited addresses; NAT allows many devices to share one public IP.
✅ Flexibility – Networks can be expanded without requiring new public IPs.
Here’s a simple network topology diagram that illustrates how private IPs, NAT, and the internet interact:
Scenario:
- A home or office network with multiple devices (PC, Laptop, Mobile).
- These devices have private IPs (e.g.,
192.168.1.X
). - A router with NAT translates private IPs to a single public IP (e.g.,
203.0.113.5
). - The router sends and receives internet traffic on behalf of all devices.
Diagram Explanation
Internet
|
[ISP Router]
|
Public IP: 203.0.113.5
|
---------------------
| NAT Router |
|---------------------|
| Private IP: 192.168.1.1 |
---------------------
|
----------------------------------
| | |
PC1 Laptop Mobile
192.168.1.10 192.168.1.11 192.168.1.12
Step-by-Step Data Flow Using NAT
- PC1 (
192.168.1.10
) wants to visitwww.google.com
. - The NAT router replaces
192.168.1.10
with Public IP (203.0.113.5
) and sends the request. - Google responds to
203.0.113.5
, not knowing about192.168.1.10
. - The router maps the response back to
192.168.1.10
using its NAT table. - PC1 gets the webpage, and this process repeats for all connected devices.
This method is called PAT (Port Address Translation), which allows multiple devices to share a single public IP.
Why is This Useful?
✅ IPv4 Conservation – We don’t need a public IP for every device.
✅ Security – Internal devices remain hidden from direct internet access.
✅ Scalability – Organizations can have thousands of internal devices without requiring public IPs.