An IP (Internet Protocol) address is a unique numerical identifier assigned to a device on a network.
It operates at Layer 3 (Network Layer) of the OSI model and is used to identify where a device is on a network so data can be routed to it — even across the entire internet.
It serves two main purposes:
- Identifies a device on a network.
- Locates the device so data can be delivered to it.
Think of it like a postal address:
- Your home address tells the postal service where to deliver mail.
- An IP address tells the internet where to deliver data packets.
1. Why Do We Need IP Addresses?
Suppose your laptop wants to open a website.
- You type www.example.com.
- The domain name is translated into an IP address using DNS.
- Your computer sends packets to that IP address.
- The web server sends the response back to your IP address.
Without IP addresses, devices wouldn't know where to send or receive information.
3. Types of IP Addresses
1. IPv4
IPv4 is the older and most widely used version.
- 32-bit address
- Four decimal numbers separated by dots
- Each number ranges from 0 to 255
Example:
192.168.1.10
172.16.0.5Structure:
192 . 168 . 1 . 10
↑ ↑ ↑ ↑
8bit 8bit 8bit 8bit = 32 bits totalEach section is called an octet.
Each address is split conceptually into two parts:
192.168.1.10
└─────┘ └──┘
Network Host
part part- Network part — identifies which network the device belongs to.
- Host part — identifies the specific device within that network.
Where this split happens is determined by the subnet mask.
Example in binary:
192 = 11000000 168 = 10101000 1 = 00000001 10 = 00001010
2. IPv6
IPv6 was introduced because IPv4 addresses were running out.
- 128-bit address
- Written in hexadecimal
- Eight groups separated by colons
Rules that make them shorter to write:
- Leading zeros in a group can be dropped:
0db8→db8 - One run of consecutive all-zero groups can be collapsed to
::(only once per address):
IPv6 exists mainly because IPv4's ~4.3 billion addresses aren't enough for all the devices in the world today.
Example:
2001:0db8:85a3:0000:0000:8a2e:0370:7334Shortened form:
2001:db8:85a3::8a2e:370:73344. Difference Between IPv4 and IPv6
| Feature | IPv4 | IPv6 |
|---|---|---|
| Full Form | Internet Protocol Version 4 | Internet Protocol Version 6 |
| Address Size | 32-bit | 128-bit |
| Format | Decimal (192.168.1.1) | Hexadecimal (2001:db8::1) |
| Number of Addresses | About 4.3 Billion | About 3.4 × 10³⁸ |
| Security | IPSec Optional | IPSec Built-in |
| Broadcast | Supported | Not Supported |
| Configuration | Manual or DHCP | Auto Configuration or DHCPv6 |
| Example | 192.168.1.1 | 2001:db8::1 |
5. Special IPv4 Addresses
| Address | Purpose |
|---|---|
| 127.0.0.1 | Loopback |
| 0.0.0.0 | Unspecified/default route |
| 255.255.255.255 | Broadcast |
| 169.254.x.x | Automatic Private IP (APIPA) |
6. IP Address Classes (Classful Addressing)
Older networking used five classes.
| Class | First Octet | Default Mask |
|---|---|---|
| A | 1-126 | 255.0.0.0 |
| B | 128-191 | 255.255.0.0 |
| C | 192-223 | 255.255.255.0 |
| D | 224-239 | Multicast |
| E | 240-255 | Experimental |
7. Subnet Mask
A subnet mask tells you how many bits belong to the network part vs. the host part.
It's often written in CIDR(Classless Inter-Domain Routing) notation (a slash followed by a number):
192.168.1.10/24The /24 means the first 24 bits (3 full octets) are the network part, leaving the last 8 bits for hosts.
Example:
IP Address: 192.168.1.20 Subnet Mask: 255.255.255.0
This means:
Network: 192.168.1.0 Host: 20
8. Default Gateway
A default gateway is the router that forwards traffic to other networks.
Example:
Computer: 192.168.1.20 Gateway: 192.168.1.1
When the computer wants to reach a website on the internet, it sends the data to the gateway first.
9. Loopback Address
Used for testing the local machine.
IPv4: 127.0.0.1
Also called: localhost
It refers to your own computer.
10. Public IP vs Private IP Addresses
| Feature | Public IP | Private IP |
|---|---|---|
| Definition | Used on the Internet | Used within a Local Network |
| Assigned By | Internet Service Provider (ISP) | Router or DHCP Server |
| Internet Access | Directly Accessible | Not Directly Accessible |
| Uniqueness | Globally Unique | Can Be Reused |
| Security | Less Secure | More Secure |
| Main Use | Websites, Servers | Home and Office Networks |
| Example | 8.8.8.8 | 192.168.1.10 |
- Public IP — globally unique, routable across the internet. Assigned by your ISP.
- Private IP — only unique within your local network (home, office). Not routable on the public internet.
Reserved Private Ranges (won't ever appear on the public internet)
- 10.0.0.0 - 10.255.255.255
- 172.16.0.0 - 172.31.255.255
- 192.168.0.0 - 192.168.255.255
Private IP addresses are not directly reachable from the public internet.
Your home router uses NAT (Network Address Translation) to let many devices with private IPs share one public IP when talking to the internet.
11. Static IP vs Dynamic IP
| Feature | Static IP | Dynamic IP |
|---|---|---|
| Definition | Fixed IP Address | Automatically Assigned IP Address |
| Assignment | Manual Configuration | DHCP Server |
| Changes | Does Not Change | Changes Automatically |
| Cost | Usually Higher | Usually Lower |
| Best For | Servers, CCTV, Printers | Computers, Smartphones |
| Maintenance | Manual | Automatic |
| Example | 203.0.113.25 | 192.168.1.25 |
- Static IP — fixed IP address that remains constant over time. Common for servers.
- Dynamic IP — automatically assigned by a DHCP server (usually your router) and may change over time. Most home devices use this.
Dynamic Host Configuration Protocol (DHCP)
It is a network management protocol used on Internet Protocol (IP) networks for automatically assigning IP addresses and other communication parameters to devices connected to the network using a client-server architecture.
This process simplifies connecting devices without the need for manual configuration.
12. How IP Addresses Work With MAC Addresses
When your device sends data:
- It checks if the destination IP is on the same network or a different network.
- If same network → uses ARP (Address Address Resolution Protocol) to find the destination's MAC address and sends directly.
- If different network → sends the data to the default gateway (your router), which forwards it onward.
You (192.168.1.10) → Router (192.168.1.1) → Internet → Destination serverThe IP address gets the data to the right network; the MAC address gets it to the right device once it arrives.
13. MAC Address vs IP Address
| Feature | MAC Address | IP Address |
|---|---|---|
| Full Form | Media Access Control Address | Internet Protocol Address |
| Definition | A unique physical address assigned to a network interface card (NIC). | A logical address assigned to identify a device on a network. |
| Address Type | Physical (Hardware) Address | Logical Address |
| Assigned By | Device Manufacturer | ISP, Network Administrator, or DHCP Server |
| Address Length | 48-bit (6 Bytes) | 32-bit (IPv4) or 128-bit (IPv6) |
| Format | Hexadecimal (00:1A:2B:3C:4D:5E) | IPv4: 192.168.1.1 IPv6: 2001:db8::1 |
| OSI Layer | Data Link Layer (Layer 2) | Network Layer (Layer 3) |
| Purpose | Identifies a device within a local network. | Identifies and locates a device across networks. |
| Can It Change? | Usually No (can be spoofed) | Yes, depending on network configuration. |
| Uniqueness | Globally unique for each network interface. | Unique within the network or Internet while assigned. |
| Main Use | Local communication between devices. | Communication over local and external networks. |
| Example | 00:1A:2B:3C:4D:5E | 192.168.1.10 |
14. Key Takeaways
- IP address: Identifies and locates a device on a network.
- IPv4: 32-bit, e.g., 192.168.1.1.
- IPv6: 128-bit, e.g., 2001:db8::1.
- Public IP: Reachable on the internet.
- Private IP: Used within local networks.
- Static IP: Fixed address.
- Dynamic IP: Assigned automatically by DHCP.
- Subnet mask: Separates network and host portions.
- Gateway: Router used to reach other networks.
- Loopback: 127.0.
- MAC address: Physical device address; IP address Logical network address.