🔢

IP Addressing (IPv4 & IPv6) Beginner

Everything about IP addresses: binary structure, classes, public vs private, CIDR, and the move to IPv6.

17 lessons 51 quiz questions
Lessons & quizzes Certificate

📚 Lessons & quizzes

Each lesson ends with its own short quiz. Answer them as you go — score 90% across all lessons to earn your certificate.

1 What an IP Address Is and Why We Need One

An IP address (Internet Protocol address) is a numeric label assigned to every device that communicates on a network. Just as a postal address tells the mail carrier where to deliver a letter, an IP address tells routers where to deliver a packet of data.

Without IP addresses, two computers would have no way to identify each other across a network. Every message on the internet is broken into packets, and each packet carries a source IP and a destination IP so the network knows where it came from and where it should go.

There are two versions in use today: IPv4 (the original, 32-bit) and IPv6 (the newer, 128-bit). This course covers both.

2 IPv4 Structure: 32 Bits in Dotted-Decimal

An IPv4 address is 32 bits long. To make it readable for humans, those 32 bits are split into four groups of 8 bits called octets, and each octet is written as a decimal number separated by dots. This is called dotted-decimal notation.

Because each octet is 8 bits, its value ranges from 0 to 255 (that is 28 = 256 possible values). So a valid IPv4 address looks like 192.168.1.10 — four numbers, each between 0 and 255.

With 32 bits total, the entire IPv4 space holds 232 ≈ 4.3 billion addresses.

# Show your IPv4 address on Linux
ip addr

# Show your IPv4 address on Windows
ipconfig

3 Converting Binary to Decimal

Each octet is 8 bits, and each bit position has a place value: 128, 64, 32, 16, 8, 4, 2, 1 (from left to right). To convert binary to decimal, add up the place values wherever there is a 1.

Worked example: the octet 11000000. The two leftmost bits are 1, so add 128 + 64 = 192.

Another: 10101000 = 128 + 32 + 8 = 168. And 00000001 = 1. So the binary address 11000000.10101000.00000001.00001010 equals 192.168.1.10 in dotted-decimal.

4 Converting Decimal to Binary

To convert a decimal octet to binary, work through the place values 128, 64, 32, 16, 8, 4, 2, 1 from left to right. At each position, ask: does the place value fit into what remains? If yes, write a 1 and subtract it; if no, write a 0.

Worked example: convert 200. 128 fits (remainder 72) → 1. 64 fits (remainder 8) → 1. 32 no → 0. 16 no → 0. 8 fits (remainder 0) → 1. 4 no → 0. 2 no → 0. 1 no → 0. Result: 11001000.

Another: 10 = 8 + 2 = 00001010. And 255 = all ones = 11111111.

5 Network Portion vs Host Portion

Every IPv4 address is split into two parts: the network portion (which network the device belongs to) and the host portion (which specific device on that network). A subnet mask decides where the split happens.

For example, with the address 192.168.1.10 and mask 255.255.255.0, the first three octets (192.168.1) are the network and the last octet (10) is the host. All devices sharing 192.168.1 are on the same local network.

Two special host values are reserved on every network: the all-zeros host is the network address (the network itself) and the all-ones host is the broadcast address (reaches every host at once).

6 Classful Addressing (A, B, C, D, E)

Before modern subnetting, IPv4 was divided into classes based on the value of the first octet:

  • Class A: first octet 1–126, default mask 255.0.0.0 (/8). Huge networks.
  • Class B: first octet 128–191, default mask 255.255.0.0 (/16).
  • Class C: first octet 192–223, default mask 255.255.255.0 (/24). Small networks.
  • Class D: 224–239, reserved for multicast (no default mask).
  • Class E: 240–255, reserved/experimental.

Note that 127 is skipped between Class A and B because it is reserved for loopback.

7 Public vs Private Addresses (RFC 1918)

Not every IPv4 address is usable on the public internet. RFC 1918 reserves three blocks for private use inside homes and organizations. These addresses are not routed on the internet, so the same private ranges can be reused by millions of networks.

The three private ranges are:

  • 10.0.0.0/8 — 10.0.0.0 to 10.255.255.255
  • 172.16.0.0/12 — 172.16.0.0 to 172.31.255.255
  • 192.168.0.0/16 — 192.168.0.0 to 192.168.255.255

A public address is any globally routable address outside these reserved ranges, assigned by an ISP. The common home address 192.168.1.10 is private.

8 The Loopback Address (127.0.0.1)

The address 127.0.0.1 is the loopback address — it always refers to the device itself. When a program sends data to 127.0.0.1, the data never leaves the machine; it loops straight back to the same computer. It is commonly nicknamed localhost.

The entire 127.0.0.0/8 block (127.0.0.0 to 127.255.255.255) is reserved for loopback, which is why 127 is skipped in the address classes. Developers use loopback to test network software locally without any physical network.

You can verify it with a ping to yourself.

# Ping your own machine via loopback
ping 127.0.0.1

# The name 'localhost' resolves to 127.0.0.1
ping localhost

9 APIPA: Automatic Private IP (169.254.x.x)

When a device is set to obtain its address automatically but cannot reach a DHCP server, it falls back to APIPA (Automatic Private IP Addressing). It self-assigns an address from the range 169.254.0.0/16 — that is 169.254.0.0 to 169.254.255.255.

An APIPA address lets devices on the same LAN segment still talk to each other, but it provides no default gateway, so there is no internet access. In practice, seeing a 169.254.x.x address is a strong clue that DHCP failed.

If you spot one, the usual cause is an unreachable or misconfigured DHCP server.

10 The Default Gateway

The default gateway is the address of the router that connects your local network to other networks (including the internet). When a device wants to send a packet to a destination outside its own network, it hands the packet to the default gateway, which forwards it onward.

In a typical home network the gateway is the router, often at an address like 192.168.1.1. Traffic for a host on the same local network goes directly; traffic for anywhere else goes through the gateway.

You can see your gateway with the commands below.

# Show the default gateway on Linux
ip route

# Show the default gateway on Windows
ipconfig

11 Static vs DHCP Assignment (DORA)

An IP address can be assigned two ways. A static address is configured manually and never changes — useful for servers and printers. A dynamic address is leased automatically by a DHCP server (Dynamic Host Configuration Protocol), which is how most laptops and phones get configured.

DHCP follows a four-step exchange remembered by the acronym DORA:

  • Discover — the client broadcasts looking for a DHCP server.
  • Offer — a server offers an address.
  • Request — the client requests the offered address.
  • Acknowledge — the server confirms the lease.

12 CIDR Notation (/24 and Friends)

CIDR (Classless Inter-Domain Routing) replaced rigid classes with a flexible slash notation. The number after the slash, the prefix length, tells you how many of the leading bits belong to the network portion.

For example, 192.168.1.0/24 means the first 24 bits are the network (equivalent to mask 255.255.255.0), leaving 8 bits for hosts. That gives 28 = 256 addresses, of which 254 are usable hosts (one is the network address, one is broadcast).

Other common prefixes: /8 = 255.0.0.0, /16 = 255.255.0.0, /24 = 255.255.255.0.

13 IPv4 Exhaustion and Why IPv6

IPv4 has only 232 ≈ 4.3 billion addresses. That sounded enormous in the 1980s, but with billions of phones, computers, and smart devices, the world ran out. The central pool of free IPv4 blocks was officially exhausted — IANA allocated its last blocks in 2011.

Two responses emerged. NAT (covered later) lets many private devices share one public IPv4 address, stretching the supply. The long-term fix is IPv6, which uses 128 bits — about 3.4 × 1038 addresses, effectively limitless.

IPv6 was designed not just for more addresses but also for simpler routing and built-in autoconfiguration.

14 IPv6 Structure: 128 Bits and Hextets

An IPv6 address is 128 bits long. Instead of four decimal octets, it is written as eight groups of 16 bits, called hextets, separated by colons. Each hextet is written in hexadecimal (digits 0–9 and letters a–f).

A full IPv6 address looks like:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

That is 8 hextets × 16 bits = 128 bits total. Hexadecimal is used because it represents 16-bit chunks far more compactly than decimal would.

# Show IPv6 addresses on Linux
ip -6 addr

# Show all addresses (including IPv6) on Windows
ipconfig /all

15 IPv6 Abbreviation Rules

Full IPv6 addresses are long, so two shortening rules apply. Rule 1: drop leading zeros within each hextet (but at least one digit must remain). Rule 2: replace one run of consecutive all-zero hextets with a double colon :: — and you may use :: only once per address.

Worked example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Drop leading zeros → 2001:db8:85a3:0:0:8a2e:370:7334. Collapse the run of zeros with ::2001:db8:85a3::8a2e:370:7334.

The reason :: may appear only once is so the address can be expanded unambiguously back to 8 hextets.

16 IPv6 Address Types

IPv6 defines several address types, each recognizable by its prefix:

  • Global unicast — routable on the public internet, typically starting 2000::/3 (addresses beginning with 2 or 3).
  • Link-local — valid only on a single link, always starting fe80::/10. Every IPv6 interface has one automatically.
  • Loopback::1, the IPv6 equivalent of 127.0.0.1.
  • Multicast — one-to-many delivery, starting ff00::/8. (IPv6 has no broadcast; multicast replaces it.)

17 NAT: Sharing One Public IP

NAT (Network Address Translation) lets many devices with private addresses share a single public address. The router rewrites the source address of outgoing packets from the private IP to its public IP, and remembers the mapping so replies are sent back to the right internal device.

For example, your laptop at 192.168.1.10 and phone at 192.168.1.11 both appear on the internet as your router’s single public address. The most common form, where many hosts share one address using port numbers to tell them apart, is called PAT or NAT overload.

NAT was a major factor in slowing IPv4 exhaustion, because a whole household needs only one public address.

🎓 Certificate of Completion

🔒 Complete every lesson quiz above with 90%+ to unlock your downloadable certificate.