AlgoInsight

Free lesson · Computer Networking

What Is An Ip Address

Easy10 min readnetworkingcomputer-networkstcp-ip

Every Device on the Internet Needs an Address

Think of the internet as a global postal system. For a letter to reach you, it needs your address - a standardized identifier that uniquely locates your mailbox among billions. Without an address, the postal system has no idea where to deliver. The same is true for the internet. For a packet to reach your laptop, your phone, or a server, it needs a destination address that uniquely identifies that device on the network.

That address is the IP address (Internet Protocol address). Every device that communicates on the internet - your laptop, your phone, the web server hosting your favorite site, the DNS server that resolved the hostname, the router that forwarded your packet - has at least one IP address. The IP address is the foundation of Layer 3 (the Network layer) and is the primary mechanism the internet uses to route packets from source to destination across networks.

MAC addresses, which you studied in Module 2, identify devices on a local network. But MAC addresses are flat - they have no structure that tells a router where the device is geographically or topologically. An IP address, by contrast, is hierarchical - it contains information about which network the device belongs to, which allows routers to make forwarding decisions without knowing every individual device on the internet.

IPv4 Address Format

The most widely used version of IP addresses is IPv4 (Internet Protocol version 4), defined in RFC 791 in 1981. An IPv4 address is a 32-bit number, meaning it is 32 ones and zeros. But writing 32 binary digits is impractical for humans, so IPv4 addresses are written in dotted decimal notation - four decimal numbers separated by dots.

Each of the four numbers represents 8 bits (1 byte), called an octet. Since 8 bits can represent values from 0 to 255, each octet ranges from 0 to 255.

IP address:    192.168.1.42
In binary:     11000000.10101000.00000001.00101010
               |octet 1||octet 2||octet 3||octet 4|

Some examples of valid IPv4 addresses: 10.0.0.1, 172.16.254.3, 8.8.8.8 (Google's public DNS), 192.168.0.1 (common home router address), 93.184.216.34 (example.com).

The 32-bit address space means IPv4 can theoretically support 2^32 = 4,294,967,296 addresses - roughly 4.3 billion. That number seemed enormous in 1981 when there were only a few hundred computers on the internet. Today, with billions of connected devices worldwide, IPv4 addresses have been exhausted. The long-term solution is IPv6 (covered in Topic 5 of this module), which uses 128-bit addresses providing a virtually unlimited address space. But IPv4 remains dominant in practice, extended by technologies like NAT (Topic 6) that allow multiple devices to share a single public IP address.

Binary Is the Truth

Understanding IP addresses in binary is not just academic - it is essential for subnetting, which you will learn in Topics 3 and 4. When you see 192.168.1.0/24, the /24 refers to the first 24 bits of the address. Without understanding that each octet is 8 bits and the entire address is 32 bits, subnet notation becomes mysterious rather than transparent.

Here is how to convert between decimal and binary for any octet:

Bit position 7 6 5 4 3 2 1 0
Value 128 64 32 16 8 4 2 1

To convert the decimal number 192 to binary: 192 = 128 + 64 = 11000000. To convert 168: 168 = 128 + 32 + 8 = 10101000. You do not need to be fast at this conversion - you need to understand that it exists and that every networking calculation ultimately operates on these 32 bits.

A useful exercise: memorize the powers of 2 from 2^0 through 2^8 (1, 2, 4, 8, 16, 32, 64, 128, 256). These eight numbers are the building blocks for all subnet math. Every subnet mask boundary, every host count calculation, every CIDR notation - they all come back to these powers of 2.

For quick reference, here are the most common octets you will encounter and their binary equivalents:

Decimal Binary Where You See It
0 00000000 Network address, wildcard
128 10000000 Subnet boundary
192 11000000 First octet of 192.168.x.x
224 11100000 Subnet mask /3 boundary
240 11110000 Subnet mask /4 boundary
248 11111000 Subnet mask /5 boundary
252 11111100 Subnet mask /6 boundary
254 11111110 Subnet mask /7 boundary
255 11111111 Full octet in subnet mask

The Two Parts of an IP Address

Every IP address has two parts, and understanding this split is the single most important concept in IP addressing:

Network portion: Identifies which network the device belongs to. All devices on the same network share the same network portion. Routers use this portion to make forwarding decisions - they route based on networks, not individual devices.

Host portion: Identifies the specific device within that network. Each device on the same network has a unique host portion.

The boundary between the network portion and the host portion is defined by the subnet mask (covered in depth in Topic 3). For now, understand that in the address 192.168.1.42 with a subnet mask of 255.255.255.0 (also written as /24):

This split is what makes IP addresses hierarchical and routable. A router does not need to know where every individual device is - it only needs to know how to reach each network. Consider the analogy of postal codes: a mail sorting facility does not need to know the location of every house in the country. It just needs to know which direction to send mail with a given postal code, and the local post office handles the final delivery. IP routing works the same way - backbone routers know how to reach major networks (large IP blocks), regional routers know how to reach smaller subnets within those networks, and local switches handle the final delivery to individual hosts.

This hierarchical approach reduces the size of routing tables from billions of individual device entries to hundreds of thousands of network entries, which is what makes internet-scale routing computationally feasible. The internet's core routers currently maintain roughly 950,000 routes - a large number, but manageable for modern routing hardware. Without hierarchical addressing, they would need 20+ billion routes (one per connected device), which would be impossible to store and search at line speed.

graph TD
    subgraph IPStructure["IP Address: 192.168.1.42 /24"]
        direction LR
        NET["Network Portion<br/>192.168.1<br/>(first 24 bits)<br/>Identifies the network"]
        HOST["Host Portion<br/>.42<br/>(last 8 bits)<br/>Identifies the device"]
    end

    subgraph Analogy["Postal Analogy"]
        direction LR
        STREET["Street Name<br/>'123 Main Street'<br/>Gets you to the<br/>right neighborhood"]
        APT["Apartment Number<br/>'Apt 42'<br/>Gets you to the<br/>specific door"]
    end

    style NET fill:#4f46e5,stroke:#4338ca,color:#fff
    style HOST fill:#7c3aed,stroke:#6d28d9,color:#fff
    style STREET fill:#4f46e5,stroke:#4338ca,color:#fff
    style APT fill:#7c3aed,stroke:#6d28d9,color:#fff
This diagram shows the two-part structure of an IP address using 192.168.1.42 with a /24 subnet mask. The network portion is 192.168.1, consisting of the first 24 bits, and it identifies the network. The host portion is .42, consisting of the last 8 bits, and it identifies the specific device. Below, a postal analogy maps the network portion to a street name that gets you to the right neighborhood, and the host portion to an apartment number that gets you to the specific door.

Public vs Private IP Addresses

Not all IP addresses are equal. Some are visible on the public internet - any device anywhere can reach them. Others are private - they work only within a local network and are invisible to the outside world.

Public IP Addresses

A public IP address is globally unique and routable on the internet. When you access google.com, your request reaches a server with a public IP address like 142.250.80.46. When Google's server sends the response, it sends it to your public IP address. Public IPs are assigned by your ISP, which gets them from a regional internet registry (ARIN, RIPE NCC, APNIC, etc.), which gets them from IANA.

Public IPv4 addresses are scarce. The last blocks of unallocated IPv4 addresses were distributed to regional registries in 2011, and each registry has since exhausted its pool (APNIC was first in 2011, RIPE NCC in 2012, LACNIC in 2014, ARIN in 2015, and AFRINIC in 2017). Today, organizations acquire public IPv4 addresses through transfers (buying allocations from other organizations at market prices that have risen to $40-50+ per address) or by using IPv6. The scarcity of public IPv4 addresses is a real economic constraint - AWS began charging $0.005 per hour for each public IPv4 address in February 2024, reflecting the real cost of this increasingly scarce resource.

Private IP Addresses

Private IP addresses are reserved for use within internal networks. They are not routable on the public internet - routers on the internet will not forward packets with private destination addresses. Three ranges are defined by RFC 1918:

Range CIDR Notation Number of Addresses Typical Use
10.0.0.0 – 10.255.255.255 10.0.0.0/8 16,777,216 Large enterprises, cloud VPCs
172.16.0.0 – 172.31.255.255 172.16.0.0/12 1,048,576 Medium enterprises
192.168.0.0 – 192.168.255.255 192.168.0.0/16 65,536 Home and small office networks

Your home router almost certainly assigns addresses in the 192.168.x.x range to your devices. AWS VPCs typically use the 10.x.x.x range. These addresses can be reused by any number of independent networks worldwide - your 192.168.1.10 and your neighbor's 192.168.1.10 coexist without conflict because they are on separate networks.

NAT (Network Address Translation), covered in Topic 6, is the technology that allows devices with private IP addresses to access the public internet. Your home router has one public IP address from your ISP and assigns private addresses to all your home devices. When a device sends a request to the internet, the router translates the private source address to the public address (and tracks the translation so responses can be delivered back to the correct device).

Special IP Addresses

Several IP addresses and ranges have special meanings:

How IP Addresses Differ from MAC Addresses

This comparison was introduced in Module 2, but it is worth revisiting now with deeper context:

IP addresses are logical and assigned. They can be changed, reassigned, and configured by software. When your laptop moves from your home network to a coffee shop's Wi-Fi, it gets a new IP address. The address reflects where the device currently is on the network, not what the device physically is.

MAC addresses are physical and permanent (mostly). They are burned into the network interface hardware and do not change when the device moves between networks. They identify the device itself, not its network location.

Both are needed because they solve different problems. IP addresses enable routing across networks (the global postal system). MAC addresses enable delivery within a single network (the local mailroom). ARP bridges the gap by translating IP to MAC when the destination is on the same local network.

graph LR
    subgraph Journey["Packet Journey: Your Laptop → Remote Server"]
        direction LR
        LAPTOP["Your Laptop<br/>IP: 192.168.1.10<br/>MAC: AA:AA"]
        ROUTER["Home Router<br/>IP: 192.168.1.1 (LAN)<br/>IP: 73.42.15.99 (WAN)<br/>MAC: RR:RR"]
        ISP["ISP Router<br/>IP: 73.42.0.1"]
        SERVER["Remote Server<br/>IP: 93.184.216.34<br/>MAC: SS:SS"]
    end

    LAPTOP -->|"Dst MAC: RR:RR<br/>Dst IP: 93.184.216.34"| ROUTER
    ROUTER -->|"Dst MAC: changes<br/>Dst IP: 93.184.216.34"| ISP
    ISP -->|"Dst MAC: SS:SS<br/>Dst IP: 93.184.216.34"| SERVER

    style LAPTOP fill:#4f46e5,stroke:#4338ca,color:#fff
    style ROUTER fill:#7c3aed,stroke:#6d28d9,color:#fff
    style ISP fill:#8b5cf6,stroke:#7c3aed,color:#fff
    style SERVER fill:#4f46e5,stroke:#4338ca,color:#fff
This diagram shows a packet traveling from your laptop to a remote server. The laptop at IP 192.168.1.10 sends a frame with destination MAC set to the router's MAC and destination IP set to 93.184.216.34. The home router, which has both a LAN IP of 192.168.1.1 and a WAN IP of 73.42.15.99, forwards the packet with a changed destination MAC but the same destination IP. The ISP router forwards it onward, and eventually the packet reaches the remote server at 93.184.216.34. The destination IP stays constant throughout the journey while the destination MAC changes at every hop.

Interview: IP addressing knowledge appears in System Design interviews in concrete ways:

"Design a VPC for a microservices architecture." - You need to choose a private IP range (usually 10.0.0.0/16 for a large VPC), divide it into subnets for different purposes (public subnets for load balancers, private subnets for application servers, isolated subnets for databases), and size each subnet appropriately for the expected number of instances.

"Why can't this service reach that service?" - Understanding IP addressing helps you diagnose connectivity issues: are the services on the same subnet? Is there a route between their subnets? Is NAT involved? Is a security group blocking traffic?

"How would you design IP addressing for a multi-region deployment?" - Each region needs non-overlapping IP ranges so that VPC peering or VPN connections can route correctly. If two regions use the same IP range, routing becomes ambiguous.

What Comes Next

The next topic covers IPv4 address classes and reserved ranges - the historical classification system that divided the IPv4 address space into categories, and the special-purpose ranges (private addresses, loopback, broadcast) that you will encounter constantly in network configuration and cloud infrastructure.

Exercise: Starter: Find your device's IP address. On Mac/Linux, run ifconfig or ip addr show. On Windows, run ipconfig. Is it a private address (10.x.x.x, 172.16-31.x.x, or 192.168.x.x)? Then find your public IP by searching "what is my IP" in a browser. Why are these two addresses different?

Intermediate: Convert the IP address 172.16.254.1 to binary. Write out all 32 bits. Then convert the binary address 00001010.00000000.00000011.00001111 back to dotted decimal. Practice converting a few more addresses until the process feels mechanical - you will need this skill for subnetting.

Advanced: Research IPv4 address exhaustion. When did IANA distribute the last /8 blocks to regional registries? When did each regional registry run out? What is the current market price for a /24 block of public IPv4 addresses? How does this scarcity affect cloud providers and their pricing for public IP addresses (AWS, for example, now charges for public IPv4 addresses)?

Back to Computer Networking