The Academy

Loading the search index…

Searches the academy on this device only.

IP addresses: IPv4, IPv6, public and private

Learn how to read an IPv4 address, why your phone and the website you visit have very different kinds of address, what IPv6 is for, and how a MAC address differs from an IP address.

30 minelementary

Marking a lesson as read does not prove you can do it. Skills count as demonstrated when you pass the quiz (not yet) and complete the practical tasks (not yet).

By the end of this lesson you will be able to

  • Read an IPv4 address and name its four parts.
  • Tell a private address from a public one using the common private ranges.
  • Explain in plain words why many devices at home can share one public address.
  • Say what a subnet is and decide whether two addresses are on the same home network.
  • Distinguish an IP address, an IPv6 address and a MAC address by what each is for.

Every packet you met in the last lesson needs an address on the envelope, otherwise it cannot be delivered. That address is the IP address. Knowing how to read one lets you recognise at a glance whether a device is on your home network, whether it has a sensible address at all, and why a message from your laptop can reach a website but a stranger on the internet cannot simply reach your laptop.

An address for every device

An IP address is a number that identifies a device on a network so that packets can be sent to it. Think of a street address. The post office does not need to know who you are; it needs a place to deliver to. In the same way, routers do not care what your laptop is called, only where it is.

The letters IP stand for Internet Protocol, which is the set of rules for addressing and forwarding packets. Two versions are in use: IPv4, the older and still most common, and IPv6, the newer one. We start with IPv4.

Reading an IPv4 address

An IPv4 address is four numbers separated by dots, for example 192.168.1.20. Each number is called an Octet and can be anything from 0 to 255. So 192.168.1.300 is not valid, because 300 is too big, and 192.168.1 is not valid either, because it has only three parts.

Diagram

An IPv4 address has four octets; the first ones usually name the network and the last names the device.

192Octet 1Part of the network
.dot
168Octet 2Part of the network
.dot
1Octet 3Part of the network
.dot
20Octet 4This device (0 to 255)
An IPv4 address has four octets; the first ones usually name the network and the last names the device.
Read this figure as text

The address 192.168.1.20 split into four labelled parts, showing network part and device part.

The address 192.168.1.20 is split into four parts. 192 is the first octet and 168 the second octet; with the third octet, 1, they name the network (the street). The fourth octet, 20, names the device on that network (the house number). Each octet is a number from 0 to 255. On a typical home network the first three numbers are the same for every device and only the last number changes.

Why this layout? A computer stores the address as 32 bits, grouped into four bytes of 8 bits. Eight bits can hold 256 different values, which is why each octet runs from 0 to 255. Four of them give about 4.3 billion possible addresses. That sounded like plenty in the 1980s, but there are now far more devices than that.

Private and public addresses

Because there are not enough IPv4 addresses for every device, the rules set aside some ranges for use inside homes and offices only. These are private addresses. Routers on the internet will not forward packets sent to them, so they can be reused in millions of homes without clashing. The three private ranges are:

The private IPv4 ranges
RangeLooks likeTypical use
10.0.0.0 to 10.255.255.25510.0.0.5Larger organisations and some home routers
172.16.0.0 to 172.31.255.255172.16.4.9Offices and some provider equipment
192.168.0.0 to 192.168.255.255192.168.1.20The most common range for home routers

Any other address is a public address: it is unique on the whole internet and is reachable from outside. Your provider gives your router one public address (it may change from time to time). Websites see that address, not the private address of your phone.

How do many private devices share one public address? The router does a clever swap called network address translation (NAT). When your phone sends a request, the router replaces your private address with its public one and remembers who asked. When the reply comes back, the router passes it to the right device. It is like a receptionist in a shared office who sends letters out under the company's address and hands incoming replies to the right desk.

Diagram

Devices use private addresses at home; the router shows one public address to the internet.

Your home (private addresses)Internet (public addresses)1sender: 203.0.113.252Phone192.168.1.21Laptop192.168.1.20Printer192.168.1.30Router192.168.1.1 / 203.0.113.25Website198.51.100.40
Devices use private addresses at home; the router shows one public address to the internet.
Read this figure as text

A network diagram with three home devices with private addresses, a router, and a website with a public address.

Inside the home zone: a phone with the private address 192.168.1.21, a laptop with 192.168.1.20 and a printer with 192.168.1.30, each joined to the router. The router has a private address of 192.168.1.1 on the home side and a public address of 203.0.113.25 on the internet side (a made-up documentation address). On the internet side is a website server with the public address 198.51.100.40. Step 1: the laptop sends a request to the router. Step 2: the router sends it on, using 203.0.113.25 as the sender. Step 3: the website replies to 203.0.113.25 and the router passes the reply to the laptop.

Subnets: who is on my street?

A Subnet is a group of addresses that are on the same local network and can talk to each other directly, without going through the router to the outside world. At home you can think of it simply: devices whose first three numbers match are usually on the same subnet. So 192.168.1.20 and 192.168.1.30 are neighbours, but 192.168.2.20 is on a different street.

The rule that decides this is the Subnet mask. The mask 255.255.255.0 means: the first three numbers name the network, and only the last one may differ. You do not need to calculate with masks yet. You only need to know that the mask is stored next to the address, and that two devices with different networks cannot talk directly even if they are in the same room.

Diagram

With the mask 255.255.255.0, only addresses sharing the first three numbers are neighbours.

Same subnet
  • 192.168.1.20
  • 192.168.1.30
  • Mask 255.255.255.0
  • First three numbers match

Can talk directly.

Different subnets
  • 192.168.1.20
  • 192.168.2.30
  • Mask 255.255.255.0
  • Third numbers differ: 1 and 2

A router is needed between them.

With the mask 255.255.255.0, only addresses sharing the first three numbers are neighbours.
Read this figure as text

A comparison of two pairs of addresses, one pair on the same subnet and one pair on different subnets.

Left column, same subnet: 192.168.1.20 and 192.168.1.30 with mask 255.255.255.0. The first three numbers, 192.168.1, match, so the two devices are on the same network and can reach each other directly. Right column, different subnets: 192.168.1.20 and 192.168.2.30 with mask 255.255.255.0. The third numbers, 1 and 2, differ, so the devices are on different networks and need a router between them.

IPv6 and MAC addresses

IPv6 was created because IPv4 ran out of room. An IPv6 address is 128 bits long, written as eight groups of letters and digits (hexadecimal) separated by colons, for example 2001:db8:85a3::8a2e:370:7334. The double colon is a shortcut for a run of zeros. IPv6 has so many addresses that every device in the world could have its own public one. Many networks run IPv4 and IPv6 side by side, and you rarely need to do anything about it.

A MAC address is a different thing. It is a hardware label of a network interface, usually written as six pairs of characters such as a4:5e:60:12:34:56. It is set by the manufacturer and used only on the local network, to deliver data from one device to the next on the same link. An IP address says where you are on the network; a MAC address says which piece of hardware you are. Phones may also use a randomised MAC address on each Wi-Fi network to protect privacy.

Diagram

IPv4, IPv6 and MAC addresses answer different questions.

IPv4Where am I? (older)
  • 192.168.1.20
  • Four numbers, 0 to 255
  • About 4.3 billion addresses
IPv6Where am I? (newer)
  • 2001:db8:85a3::8a2e:370:7334
  • Eight hexadecimal groups
  • Practically unlimited
MACWhich hardware am I?
  • a4:5e:60:12:34:56
  • Six pairs of characters
  • Used only on the local link
IPv4, IPv6 and MAC addresses answer different questions.
Read this figure as text

Three columns comparing IPv4, IPv6 and MAC addresses.

IPv4: four numbers from 0 to 255 separated by dots, for example 192.168.1.20. It says where a device is on a network. About 4.3 billion possible addresses. IPv6: eight groups of hexadecimal characters separated by colons, for example 2001:db8:85a3::8a2e:370:7334. It also says where a device is, with a vastly larger supply. MAC address: six pairs of characters, for example a4:5e:60:12:34:56. It labels a piece of network hardware and is used only on the local link.

Practise reading addresses

The exercises below use made-up addresses. Work through them until spotting private ranges and matching subnets feels automatic.

Decide whether addresses are valid, private or public, and which devices share a network.

Loading lab…

Common mistakes

  • ✖ Instead of: Thinking your phone's address is the one websites see.

    ✔ Do this: Websites see your router's public address. Your phone's private address only means something inside your home network.

  • ✖ Instead of: Treating a MAC address and an IP address as the same thing.

    ✔ Do this: A MAC address labels hardware on the local link; an IP address says where a device is on a network, and can change when you join a different network.

  • ✖ Instead of: Assuming any address starting with 172 is private.

    ✔ Do this: Only 172.16 to 172.31 is private. 172.32.x.x is a public range.

If something goes wrong

I cannot work out whether my address is private.
Compare it with the three ranges in the table: 10.x.x.x, 172.16 to 172.31, and 192.168.x.x. If it starts with one of them it is private.
The IP exercises show an answer I disagree with.
Check the number of parts first (four), then that each part is between 0 and 255, then compare with the private ranges. Most disagreements come from skipping the first check.

Key terms

IPv4
The older and still most common kind of IP address, written as four numbers separated by dots.
Octet
One of the four numbers in an IPv4 address; each runs from 0 to 255.
Private IP address
An address used only inside a home or office network, which is not reachable directly from the internet.
Public IP address
The address your network shows to the internet, normally given by your provider.
Subnet
A group of addresses that belong to the same local network and can reach each other directly.
Network address translation (NAT)
The router's trick of letting many private devices share one public address.

Practise it for real

Reading is not the same as being able to do it. Complete these on your own computer, then tick only what you have actually done. These ticks are your own honest record: nothing checks them for you.

Guided exercise

Sort ten addresses

On paper, write these ten made-up addresses and mark each one as private (P), public (U) or not valid (X): 192.168.0.14, 8.8.4.4, 10.20.30.40, 172.16.5.5, 172.32.5.5, 192.168.1.256, 203.0.113.9, 192.168.1, 10.0.0.1, 198.51.100.7. Then write one sentence explaining your choice for the two that surprised you most. Check your answers with the table of ranges above.

You have succeeded when:
Independent challenge

Challenge: who are the neighbours?

A home router has the address 192.168.1.1 and mask 255.255.255.0. Joseph's phone is 192.168.1.44, Fatuma's laptop is 192.168.1.9, a camera is 192.168.2.9 and a printer is 10.0.0.9. Without looking at notes, decide which devices can reach each other directly and which would need a router, and explain how you decided. Then use the lab to check similar cases.

You have succeeded when:

Knowledge check

6 questions. You need 80% to pass. Mistakes here are part of learning, and you can retry as often as you like.

  1. Question 1.Which of these is a valid IPv4 address?
  2. Question 2.A private address such as 192.168.1.20 can be reached directly by anyone on the internet.
  3. Question 3.Match each example with the best description.
  4. Question 4.Two laptops both have the mask 255.255.255.0. Wanjiru's is 192.168.1.15 and Kamau's is 192.168.5.15.What is true?
  5. Question 5.Put the steps in order for a laptop opening a website from home.
    1. The router swaps in its public address and forwards the request
    2. The website replies to the public address
    3. The router passes the reply to the laptop
    4. The laptop sends a request using its private address
  6. Question 6.A laptop shows the address 169.254.33.8 and has no internet. What does this most likely mean?

Summary

  • An IPv4 address is four octets, each 0 to 255, naming a network and a device.
  • Private ranges (10.x.x.x, 172.16 to 172.31, 192.168.x.x) are for inside the home; public addresses are unique on the internet.
  • NAT lets a router share one public address among many private devices.
  • Devices on the same subnet share the network part of the address and can talk directly.
  • A MAC address labels hardware on the local link; IPv6 is the roomier newer address style.

Checklist: can you do these?

Marking a lesson as read does not prove you can do it. Skills count as demonstrated when you pass the quiz (not yet) and complete the practical tasks (not yet).

Related lessons

References and further reading

Official sources for details that can change between versions.

On this page