Private IP addresses are one of the fundamental concepts in computer networking. To understand them properly, you should understand not just their definition, but also why they exist, how devices communicate using them, how routers handle them, and how they relate to public IP addresses, NAT, firewalls, and cloud networking.
Let's build the understanding step by step, starting from real-world examples and moving towards the technical details.
1. First, what is an IP address?
An IP (Internet Protocol) address is a logical address assigned to a device or network interface so that it can communicate over an IP network. Think of it like a postal address.
For example, imagine you have the following devices at home:
|
Device |
IP Address |
|
Laptop |
192.168.1.101 |
|
Smartphone |
192.168.1.102 |
|
Smart TV |
192.168.1.103 |
|
Desktop |
192.168.1.10 |
|
Printer |
192.168.1.20 |
|
IOP Devices |
192.168.1.130 |
All these devices are connected to the same Wi-Fi network. Each device needs an IP address so that other devices know where to send network packets.
For example:
- Your laptop wants to print a document.
- The laptop sends network packets to Router (192.168.1.1).
- The router/network infrastructure helps deliver those packets to the printer (192.168.1.20).
These IP addresses are examples of private IP addresses.
2. What exactly is a private IP address?
A private IP address is an IP address reserved for communication within private networks.
These addresses are not globally routable on the public internet.
In simple terms:
- Devices inside your home can communicate using private IP addresses.
- Devices inside your company's internal network can communicate using private IP addresses.
- Cloud servers inside an AWS or Azure private network can communicate using private IP addresses.
- Internet routers do not allow private IP addresses to be directly accessed over the public internet.
For example:
Laptop : 192.168.1.101
Smartphone : 192.168.1.102
Smart TV : 192.168.1.103
These devices can communicate inside your private network without each needing a globally unique public IP address.
Important: Private does not mean encrypted, hidden, or automatically secure. It only describes the address's routing scope.
3. What are the private IPv4 address ranges?
This is particularly important to remember. The Internet Engineering Task Force (IETF) defined three private IPv4 address ranges in RFC 1918.
Class A Private IP Range
• Address Range: 10.0.0.0 to 10.255.255.255
• CIDR Notation: 10.0.0.0/8
• Subnet Mask: 255.0.0.0
• Total Addresses: ~16.7 million (designed for very large enterprise or cloud networks)
Class B Private IP Range
• Address Range: 172.16.0.0 to 172.31.255.255
• CIDR Notation: 172.16.0.0/12
• Subnet Mask: 255.240.0.0 (or 255.255.0.0 per subnet)
• Total Addresses: ~1 million (designed for medium-sized organizations)
Class C Private IP Range
• Address Range: 192.168.0.0 to 192.168.255.255
• CIDR Notation: 192.168.0.0/16
• Subnet Mask: 255.255.0.0 (or 255.255.255.0 per /24 subnet)
• Total Addresses: ~65,536 (the most common range for home and small office networks)
3.1 CIDR Notation
CIDR (Classless Inter-Domain Routing) notation is a compact way to write an IP address and its subnet mask together. It replaces rigid Class A, B, and C boundaries with a flexible system that allocates IP addresses based on actual network size rather than fixed classes.
How a CIDR Block is Structured?
A CIDR address consists of two parts separated by a forward slash (/):
• The Network Prefix: The base IPv4 address (e.g., 192.168.1.0).
• The Prefix Length: A number from 0 to 32 (e.g., /24) that counts how many binary bits from left to right are locked to identify the network.
An IPv4 address is made of 32 bits, split into four 8-bit groups (octets) separated by dots.
• Network Bits (Ones): The number after the slash tells routers how many bits from the left belong to the network ID. These bits stay fixed for every device on that network.
• Host Bits (Zeros): The remaining bits (32 - prefix length) identify individual devices (hosts) inside that network.
For example, in 192.168.1.0/24:
• The first 24 bits (192.168.1) are locked as the network address.
• The remaining 8 bits (32 - 24 = 8) are available for device addresses (.0 through .255).
What is Subnet Mask?
A subnet mask is a 32-bit number that divides an IPv4 address into two distinct parts: the network address and the host (device) address. It tells your computer and router which devices are on your local network and which traffic needs to be sent out to the internet.
Like an IPv4 address, a subnet mask is written as four numbers (octets) separated by dots, such as 255.255.255.0. Behind the scenes, your device reads these numbers in binary (1s and 0s).
• 255 (Binary 11111111): Locks that section of the IP address to represent the Network ID. Every device on the same local network shares these exact numbers.
• 0 (Binary 00000000): Leaves that section open for the Host ID. Each device on the network gets its own unique number here.
Imagine your computer has an IP address of 192.168.1.45 and a subnet mask of 255.255.255.0.
|
Component |
First Octet |
Second Octet |
Third Octet |
Fourth Octet |
|
IP Address |
192 |
168 |
1 |
45 |
|
Subnet Mask |
255 |
255 |
255 |
0 |
|
Meaning |
Network |
Network |
Network |
Device (Host) |
Here:
• Network Portion (192.168.1): This identifies your local neighborhood or home Wi-Fi network.
• Host Portion (.45): This identifies your specific laptop on that network.
Why do we need private IP Addresses?
Imagine there are 5 billion devices connected to the internet. If every device needed a unique public IPv4 address, we would run out of IPv4 addresses.
IPv4 uses
32 bits. That means the total number of possible IPv4 addresses is: . Approximately 4.3 billion addresses.
But the number of internet-connected devices has grown far beyond that. Private IP addresses help solve this problem.
Instead of assigning a unique public IP to every device, we can reuse private IP addresses across different networks.
This is one of the biggest advantages of private IP addressing. Two different companies can have thousands of devices using 10.0.0.1 without any conflict, provided their private networks are isolated or appropriately routed.
5. Public IP vs Private IP
Now let's understand the difference.
A public IP address is globally routable on the internet. It allows a network interface or service to be addressed across the public internet, subject to firewall and routing rules.
A private IP address is intended for communication within private networks.
6. How to calculate Network Size?
You can find the
total number of IP addresses in any CIDR block using the formula , where n is the CIDR prefix number.
|
CIDR Prefix |
Host Bits Remaining (32 - n) |
Equivalent Subnet Mask |
Total IP Addresses |
Usable Host IPs |
|
/8 |
24 bits |
255.0.0.0 |
2²⁴ = 16,777,216 |
16,777,214 |
|
/16 |
16 bits |
255.255.0.0 |
2¹⁶ = 65,536 |
65,534 |
|
/24 |
8 bits |
255.255.255.0 |
2⁸ = 256 |
254 |
|
/28 |
4 bits |
255.255.255.240 |
2⁴ = 16 |
14 |
|
/30 |
2 bits |
255.255.255.252 |
2² = 4 |
2 |
Usable host IPs subtract 2 from the total because the very first address is reserved for the Network ID and the very last address is reserved for the Broadcast Address.
In any IPv4 subnet, the Network ID is the very first address that names the network itself, and the Broadcast Address is the very last address used to send a message to every device on that network at the same time. Neither address can be assigned to an individual device like a laptop or phone, which is why you subtract 2 from the total IP count.
7. How to find the private IP Address of your computer?
To find your private IP address on a Mac using the Terminal, run ipconfig getifaddr en0 for a Wi-Fi connection.
• Wi-Fi Connection: Run ipconfig getifaddr en0 in the Terminal app. It outputs only your clean IPv4 address (such as 192.168.1.45).
• Wired Ethernet Connection: Run ipconfig getifaddr en1 if you are connected via an Ethernet cable or adapter.
• All Active Connections: Run ifconfig | grep "inet " to list every local IPv4 address across all network interfaces. Ignore 127.0.0.1, as that is your Mac's internal loopback address.
Alternative Method in MAC (No Terminal)
Hold the Option key on your keyboard and click the Wi-Fi icon in the top-right menu bar. Your private IP address appears directly beneath your active network name.
Summary
Here are the seven concepts I would want you to be comfortable explaining:
• Private IP: An address used within a private network, not globally routable on the public internet.
• Public IP: An address that can be globally routed on the internet.
• RFC 1918: Defines the three private IPv4 address ranges.
• Subnet mask / CIDR: Defines the network and host portions of an IP address.
• Default gateway: Routes traffic to destinations outside the local subnet.
My recommendation for your next learning step: Study subnetting and CIDR notation in depth. Once you understand how 10.0.0.0/16, 10.0.1.0/24, and 10.0.2.0/24 relate to each other, private networking, routing tables, VPCs, firewalls, and Kubernetes networking will become much easier to understand.
You may like
Utility class to get primitive type from wrapper type and vice versa
FNV hash algorithm implementation in Java
Controlling Randomness in Java: Exploring the Role of Seeds in java.util.Random
Calculating initial capacity from expected size and load factor
A Beginner's Guide to UUID Types
Implementing LRU Cache in Java Using HashMap and Doubly Linked List

No comments:
Post a Comment