Networking - Public IP vs Private IP
1. What is an IP Address?
An IP address (Internet Protocol address) is a unique number assigned to every device connected to a network.
It’s like a home address for your device so data can reach the right place.
-
Example:
192.168.1.10
or203.122.45.67
-
Two versions exist:
-
IPv4 → 32-bit address (e.g.,
192.168.0.1
) -
IPv6 → 128-bit address (e.g.,
2401:4900:30f0:1b2::2
)
-
2. Public IP Address
A Public IP is an IP address that is assigned by your Internet Service Provider (ISP) and is accessible over the Internet.
Characteristics
-
Globally unique → No two devices on the internet have the same public IP.
-
Assigned by ISP or IANA (Internet Assigned Numbers Authority).
-
Used for direct communication between devices over the internet.
-
Needed for hosting websites, online gaming servers, VPN servers, etc.
Example Ranges
Public IPs exclude private ranges (we’ll discuss below).
For example:8.8.8.8
→ Google DNS142.250.190.78
→ google.com
Pros
-
Accessible from anywhere.
-
Suitable for servers and online services.
Cons
-
Limited in number (especially IPv4).
-
Less secure if exposed directly.
3. Private IP Address
A Private IP is an IP address used inside a local network (LAN) and not directly accessible from the internet.
Characteristics
-
Used for communication within a private network.
-
Assigned manually or automatically using DHCP.
-
Cannot be routed on the internet.
-
Multiple private networks can reuse the same IP range.
Private IP Ranges (IPv4)
Class | Private IP Range | Subnet Mask |
---|---|---|
Class A | 10.0.0.0 → 10.255.255.255 | 255.0.0.0 |
Class B | 172.16.0.0 → 172.31.255.255 | 255.240.0.0 |
Class C | 192.168.0.0 → 192.168.255.255 | 255.255.0.0 |
Example:
-
Router IP →
192.168.1.1
-
Laptop →
192.168.1.5
-
Mobile →
192.168.1.10
Pros
-
Conserves public IP addresses.
-
Increases security by isolating devices from direct internet exposure.
Cons
-
Cannot access the internet directly without NAT.
4. NAT (Network Address Translation)
Since private IPs cannot access the internet directly, NAT converts a private IP into a public IP.
Example:
-
Your laptop →
192.168.1.5
(private) -
Router converts it →
103.45.21.67
(public) -
Data goes to the internet → Response comes back → Router translates it back.
5. Key Differences Between Public and Private IP
Feature | Public IP | Private IP |
---|---|---|
Visibility | Visible on the internet | Hidden from the internet |
Assigned by | ISP / IANA | Router / DHCP / Manual |
Accessibility | Accessible globally | Only within local network |
Uniqueness | Globally unique | Can repeat in different networks |
Security | Less secure | More secure |
Example | 8.8.8.8 |
192.168.1.10 |
6. Diagram
INTERNET
|
Public IP: 103.45.21.67 ← Assigned by ISP
|
┌───────────┐
│ Router │
└───────────┘
| | |
192.168.1.2 192.168.1.5 192.168.1.10
Laptop Mobile Printer
(Private IPs used inside LAN)