Know More About Internet Protocol(IP) Address Types

Types of IP Addresses

IP addresses are categorized into four main types based on how and where they are used. Let’s break them down:


1. Private IP Addresses (Used Inside Your Network)

private IP address is used within your home, office, or any private network. These addresses are not visible to the internet. Think of them as room numbers inside an apartment building—unique within the building but not visible to outsiders.Examples of Private IP Ranges:

  • 192.168.0.0 – 192.168.255.255 (commonly used in homes)
  • 10.0.0.0 – 10.255.255.255
  • 172.16.0.0 – 172.31.255.255

Workflow Example:

  • Your laptop might have the IP 192.168.1.2.
  • Your phone might have the IP 192.168.1.3.
  • These devices communicate with each other through your Wi-Fi router.

Private IPs cannot access the internet directly. Instead, your router uses NAT (Network Address Translation) to convert them into a public IP.


2. Public IP Addresses (Used on the Internet)

public IP address is what the internet sees. It’s assigned to your router (or device) by your Internet Service Provider (ISP). Public IPs are like the street address of your apartment building—visible to everyone on the internet. Examples:

  • 203.0.113.1
  • 142.250.190.78

Workflow Example:

  • Your router has a public IP (e.g., 203.0.113.1).
  • When you send a request to a website, the website responds to your public IP, and your router forwards the data to the correct device in your network.

3. Static IP Addresses (Fixed Address)

static IP address is an address that doesn’t change. It’s manually assigned to a device or server and remains constant over time. Static IPs are often used for servers, websites, and devices that need to be reliably accessible. Examples:

  • Web hosting servers (e.g., 8.8.8.8 for Google DNS).
  • Corporate networks or printers that need a fixed address.

Workflow Example:

  • Let’s say you host a website on a server with a static IP (203.0.113.5).
  • Anyone accessing your website will always use this IP, ensuring it’s reachable at all times.

4. Dynamic IP Addresses (Changes Over Time)

dynamic IP address is assigned temporarily by a DHCP (Dynamic Host Configuration Protocol) server. It may change over time (e.g., when you reconnect to the network or restart your router). Most home users are assigned dynamic IPs by their ISPs. Examples:

  • Your home Wi-Fi might have a public IP like 203.0.113.20, but it could change to 203.0.113.25 the next day.

Workflow Example:

  • Your ISP assigns your router a public IP (e.g., 203.0.113.20).
  • When you reconnect later, the IP might change, but the process is seamless for you as a user.

Special Types of IP Addresses

In addition to the four main categories, there are some special types of IP addresses worth mentioning:

  1. Loopback Address:
    • Used to test your own device without leaving your network.
    • Example: 127.0.0.1 (IPv4) or ::1 (IPv6).
  2. Broadcast Address:
    • Sends data to all devices on the network.
    • Example: 192.168.1.255.
  3. Multicast Address:
    • Sends data to a specific group of devices.
    • Example: 224.0.0.0 – 239.255.255.255.

Code Example: Identifying Your IP Address

Let’s write Python code to identify your private and public IP addresses.

1. Finding Your Private IP Address

python

import socket

# Get your private IP address
hostname = socket.gethostname()
private_ip = socket.gethostbyname(hostname)

print(f"Your private IP address is: {private_ip}")

Output Example:

Your private IP address is: 192.168.1.2

2. Finding Your Public IP Address

To find your public IP, you can use an external service like https://api64.ipify.org. Here’s an example:

python

import requests

# Get your public IP address
response = requests.get("https://api64.ipify.org?format=json")
public_ip = response.json()["ip"]

print(f"Your public IP address is: {public_ip}")

Output Example:

Your public IP address is: 203.0.113.20

Workflow Recap

Here’s how the different IP address types work together in a typical internet interaction:

  1. Private IPs in Your Network:
    • Your laptop: 192.168.1.2
    • Your phone: 192.168.1.3.
  2. Router’s Public IP:
    • Your router translates your private IPs into its public IP (e.g., 203.0.113.20) using NAT.
  3. Dynamic or Static Assignment:
    • Your ISP assigns your router either a dynamic or static public IP.
  4. Internet Communication:
    • When you access a website, your request is sent from your public IP to the website’s IP, and the response is routed back to your private IP.

Final Thoughts

Understanding the different types of IP addresses is essential for navigating the internet and developing reliable applications. Here’s a quick summary:

  • Private IPs: Used within your local network.
  • Public IPs: Used to communicate with the internet.
  • Static IPs: Fixed addresses that don’t change.
  • Dynamic IPs: Temporary addresses assigned by your ISP.

With the provided explanations, workflows, and code examples, you can now identify and differentiate between these IP address types and understand how they work in real-world scenarios.

Proudly powered by WordPress | Theme: Code Blog by Crimson Themes.