IP Addresses and Subnets
Level 2 · Addresses and ports
What an IP address is and how to read one like 192.168.1.20. What a subnet and /24 mean, and why 127.0.0.1 always means this machine.
Course contentsLesson 3 of 13
Level 1 · Networks and packets
Level 2 · Addresses and ports
Level 3 · How data travels
Level 4 · HTTP, the language of the web
Level 5 · Locked lines and go-betweens
After this lesson you can
- Read an IPv4 address
- Say how many addresses a /24 holds
- Explain what localhost is for
11 mincovers 3 glossary entries
Worth reading first: Packets and the OSI Model
How to read an IP address
An IP address is the number that marks one device on a network. Packets use it to find the device. The common kind is written as four numbers with dots, such as 192.168.1.20. Each number runs from 0 to 255, which allows about 4.3 billion addresses in all.
That is not enough for every phone, laptop and server on Earth. So a newer kind, IPv6, uses much longer numbers, such as 2001:db8::20. There are so many of them that no one will run out. Most networks now carry both kinds side by side.
Addresses come in blocks called subnets. A subnet is written with a slash, such as 192.168.1.0/24. The number after the slash says how much of the address is fixed for the whole block. With /24, the first three numbers stay the same and only the last one changes.
So 192.168.1.0/24 holds 256 addresses, from .0 to .255. The first and the last are kept back for the network itself, which leaves 254 for devices. A /16 fixes only the first two numbers and holds 65,536. A smaller number after the slash means a bigger block.
Devices in the same subnet talk to each other straight away. To reach an address outside the block, they send the packet to the router. So the subnet tells each device which addresses are its neighbours and which are far away.
Every computer also has a name for itself: localhost. Its address is 127.0.0.1. Data sent there never leaves the machine. Coders use it to test a website on their own laptop before anyone else can see it.
People often type a server's private address from outside its network. Then nothing happens. An address like 192.168.1.20 only works inside its own building. The same number is in use in millions of homes at once, and the next lesson shows how.
Worked example
Emma finds her printer
Emma's laptop has the address 192.168.1.14 and her printer has 192.168.1.30. Both start with 192.168.1, so they are on the same /24.
The laptop sends to the printer directly, without the router. When she opens a website, the laptop sees an address outside 192.168.1. It hands those packets to the router at 192.168.1.1.
The words for this lesson3
Check yourself
How many devices fit in the subnet 192.168.1.0/24?
Finished this lesson?
Marking it complete also marks its 3 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.