lesson 3.1 · chapter 3 of 5: addresses · 20 min
What's an IP address?
objective
Read an IPv4 address, turn any of its numbers into binary, tell its network part from its host part, and explain why a laptop’s IP address changes when it moves but its MAC address doesn’t.
A name and an address
Your name and where you live
You have a name, and it goes wherever you go. You also have a home address, and that changes when you move house. If a friend in another country wants to post you a letter, your name alone isn’t enough: the post office needs the address, with the country, town and street, to know where to take it.
Every host already has a MAC address (from lesson 1.1): that’s its name. It never changes, and it’s only used to get a frame to the next stop on the same network (layer 2).
So hosts get a second address, an IP address: that’s their home address. It depends on which network they’re plugged into, and it’s used to get a packet across the world, through lots of networks and routers (layer 3). IP stands for Internet Protocol: the agreed rules (a protocol) for addressing and delivering packets across the internet.
in one sentence A MAC address is a host’s name; an IP address is where it lives right now.
What one looks like
The IP addresses in this course are IPv4 addresses (Internet Protocol version 4). They look like this:
192.168.1.10
Four numbers with dots between them. Each number can be anything from 0 to 255, so 192.168.1.300 isn’t a
real address. Each of the four numbers is called an octet (oct means eight, like an octopus’s eight arms),
because inside the computer each one is made of 8 bits. Four octets make 32 bits in all.
in one sentence An IPv4 address is four numbers from 0 to 255 with dots between, like 192.168.1.10.
Numbers as light switches
Remember that a bit is a 1 or a 0, like a light switch that’s on or off. Imagine a row of 8 light switches, and each switch is worth a different amount: 128, 64, 32, 16, 8, 4, 2 and 1. To make a number, switch on the ones that add up to it. That’s called binary: counting with only 1s and 0s.
| switch worth | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | add up the 1s |
|---|---|---|---|---|---|---|---|---|---|
| 192 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 128 + 64 = 192 |
| 168 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 128 + 32 + 8 = 168 |
| 10 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 8 + 2 = 10 |
| 255 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | all on = 255 |
That’s why 255 is the biggest: it’s all eight switches on.
in one sentence Each octet is 8 bits, and binary turns them into a number by adding up the switches that are on.
The street and the house number
A home address has a street (shared by everyone who lives on it) and a house number (different for each house). An IP address is split the same way:
- the network part is the street: every host on the same network has the same one.
- the host part is the house number: different for every host on that network.
For 192.168.1.10 on a home network, 192.168.1 is the network (every device at home starts with it) and 10
is this host. Exactly where the line between the two goes is the next lesson.
in one sentence The front of an IP address says which network, the end says which host on it.
Private and public addresses
Think of a hotel. Inside, the rooms have numbers, like room 214, and every hotel in the world has a room 214. But to post a letter to the hotel, you use its street address, which is unique. The front desk takes the letter and brings it up to the right room.
IP addresses work the same way. Some are kept for use inside homes, schools and companies, and are never used out on the internet. They’re called private addresses (the room numbers):
| Private addresses | Start with |
|---|---|
10.0.0.0 to 10.255.255.255 | 10. |
172.16.0.0 to 172.31.255.255 | 172.16. up to 172.31. |
192.168.0.0 to 192.168.255.255 | 192.168. |
Every other address is public: a real, unique address out on the internet (the street address). Millions of
homes all use 192.168.1.something inside, and that’s fine, because the home router acts like the front desk:
it swaps the private address for the home’s one public address on the way out, and back again on the way in.
That swap is called NAT, network address translation (translation means changing one thing into
another).
in one sentence Private addresses are used inside a home or school; public addresses are unique on the internet; the router swaps between them.
And IPv6?
There are only about 4 billion IPv4 addresses, and that isn’t enough for every phone, laptop and smart light
bulb on Earth. So there’s a newer version, IPv6 (Internet Protocol version 6), with much longer addresses
that look like 2001:db8::10. They work the same way, with far more addresses. This course sticks to IPv4,
because it’s still what you’ll see first.
in one sentence IPv6 is the newer version with far more addresses; the ideas are the same.
Same name, new address
Your laptop at home, then at school. Watch what changes and what doesn’t.
in one sentence When a laptop moves to a new network it keeps its MAC address but gets a new IP address.
IP addresses go the whole way, MAC addresses go one hop
Here’s why a host needs both. You load a web page from a server far away. The packet crosses your home router and your internet provider’s router. (Your ISP, internet service provider, is the company that brings the internet to your home.) Each trip from one box to the next is called a hop. Step through and watch the frame box: what changes at each hop, and what stays the same?
See the bits
Type any IPv4 address in the box: try your own, or 10.0.0.1, or 255.255.255.255. Under each number you’ll
see its 8 bits. The blue bits are the network part and the amber bits are the host part; leave the slider
on /24 for now. Moving it is the next lesson.
That isn't an IPv4 address yet: four numbers from 0 to 255, with dots between, like 10.0.0.1.
network bits host bits
Try it on your own computer (optional)
- Windows: in Command Prompt,
ipconfig. Look for IPv4 Address. - Mac: System Settings → Wi-Fi → Details… → TCP/IP, or in Terminal:
ipconfig getifaddr en0.
Is yours private? (Almost certainly: check the table at the top.) Then visit a what’s my IP website: it shows your home’s public address, the one your router uses on the internet.
in one sentence IP addresses stay the same from start to finish; MAC addresses change at every router.
Valid, private or public?
For each one: is it a valid IPv4 address? If it is, is it private or public?
192.168.0.110.300.2.18.8.4.4172.20.10.5172.40.10.5192.168.110.0.0.255
And a bonus: what’s 10101010 in ordinary numbers?
hint
Valid means four numbers, each from 0 to 255.
hint
Private is anything starting 10., 192.168., or 172. followed by a number from 16 to 31.
hint
For the bonus, write the bit values over it: 128 64 32 16 8 4 2 1. Add up the ones under a 1.
show the solution
| Address | Valid? | Private or public |
|---|---|---|
192.168.0.1 | ✅ | private (starts 192.168.) |
10.300.2.1 | ❌ | 300 is bigger than 255 |
8.8.4.4 | ✅ | public |
172.20.10.5 | ✅ | private (20 is between 16 and 31) |
172.40.10.5 | ✅ | public (40 is outside 16 to 31) |
192.168.1 | ❌ | only three numbers |
10.0.0.255 | ✅ | private (starts 10.) |
Bonus: 10101010 = 128 + 32 + 8 + 2 = 170.
5 check: test yourself
Pick an answer for each question. You'll see straight away whether it's right, and why. Questions marked what happens next? are about the animations.
Which of these is a real IPv4 address?
Four numbers, each from 0 to 255.
256is too big, and172.16.5only has three numbers.what happens next?In the animation, you take your laptop from home to school and join the school’s Wi-Fi. What happens next?
The MAC address is its name and never changes. The IP address is where it lives, so a new network means a new one.
What’s
11000000in ordinary numbers?The two left-hand switches are on: 128 + 64 = 192.
A packet travels from your laptop, through two routers, to a web server. What stays the same the whole way?
The IP addresses are the start and end of the whole trip. The MAC addresses change at every router, because each frame only goes to the next stop.
Which of these is a private address, the kind only used inside a home or school?
Anything starting
192.168.is private: a hotel room number, not a street address.