A phone repair shop opens
A phone repair shop is opening on the high street. It has two tills, a card reader, a printer, three staff laptops and free Wi-Fi for customers.
Every one of those needs its own address on the network. If two devices get the same address, both stop working properly.
So before anything is plugged in, somebody writes a plan.
By the end of this lesson
Note
I can plan addresses for a small office.
Key words
| Word | What it means | Example |
|---|---|---|
| IP address | the number that finds one device on a network | 192.168.1.37 |
| Network part | the start of an address, the same for every device in one network | |
| Host part | the end of an address, different for each device | |
| Prefix | how many bits are the network part, written after a slash | /24 |
| Subnet | a smaller network cut out of a bigger one | |
| Address plan | a list of which device gets which address |
The cells students fill in are left blank in this preview.
Before you start
Note
Press Start the lab on the bar at the top. The lab is a whole Ubuntu machine of your own, with small pretend computers built inside it. Each Run button types its command into the terminal. If a Run says the machine is still starting, wait and press it again.
An address has two parts
An IP address is four numbers, each from 0 to 255, with dots between them.
The prefix after the slash says how much of the address is the network part. A /24 means the first three numbers. Every device in that network shares them. The last number is the host part, and it is different for each device.
Worked example: one address in a /24
| Written as | Network part | Host part | Addresses in the network |
|---|---|---|---|
| 192.168.1.37/24 | 192.168.1 | 37 | 256, from .0 to .255 |
| 192.168.1.200/24 | 192.168.1 | 200 | The same 256 |
| 192.168.2.37/24 | 192.168.2 | 37 | A different network |
The cells students fill in are left blank in this preview.
Read the lab's machines and addresses
netlab statusShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
What the lab shows
The lab has two routers, r1 and r2, and three computers, h1, h2 and mgmt. Each line gives a cable and its address, such as to-r1 10.0.1.2/24.
Look at h1 and r1. One is 10.0.1.2/24, the other 10.0.1.1/24. The network part, 10.0.1, is the same, so they are on one network.
Count the addresses in a /24
python3 -c "print(__import__('ipaddress').ip_network('192.168.1.0/24').num_addresses)"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Cutting a network into smaller ones
The shop does not want customers on the same network as the tills. So it cuts its /24 into subnets.
Each step up in the prefix halves the network. A /25 is half a /24. A /26 is a quarter, so a /24 makes four /26 networks of 64 addresses each.
In every network, the first address names the network and the last is the broadcast address, which reaches every device. Neither can be given to a device.
Worked example: four /26 networks
| Subnet | First device | Last device | Broadcast | Used for |
|---|---|---|---|---|
| 192.168.1.0/26 | .1 | .62 | .63 | Tills, card reader, printer |
| 192.168.1.64/26 | .65 | .126 | .127 | Staff laptops |
| 192.168.1.128/26 | .129 | .190 | .191 | Customer Wi-Fi |
| 192.168.1.192/26 | .193 | .254 | .255 | Kept spare |
The cells students fill in are left blank in this preview.
Let Python cut the /24
python3 -c "print(list(__import__('ipaddress').ip_network('192.168.1.0/24').subnets(new_prefix=26)))"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
A common mistake
Warning
Many people think a /24 holds 256 devices. It holds 256 addresses, but the first names the network and the last is the broadcast. So only 254 devices fit, and the router takes one of those.
A plan says who gets which address
A good plan follows a few habits. The router takes the first device address. Things that must never move, such as a printer or a till, get fixed addresses at the low end.
Phones and laptops come and go, so a range is kept for them to borrow. You will see how they borrow one next lesson.
Leave some room. A shop that grows from three laptops to ten should not need a new plan.
Worked example: the tills network
| Address | Device | Kind |
|---|---|---|
| 192.168.1.1 | The router | Fixed |
| 192.168.1.2 and .3 | Till 1 and till 2 | Fixed |
| 192.168.1.4 | The card reader | Fixed |
| 192.168.1.10 | The printer | Fixed |
| 192.168.1.20 to .60 | Anything that joins later | Borrowed |
The cells students fill in are left blank in this preview.
Going further: a bigger shop
The shop opens a second branch. It needs 40 customer devices, 12 staff laptops and 5 tills.
Use plan_lines from your assignment to pick a prefix for each group. Then cut 192.168.5.0/24 by hand so the three groups fit without overlapping. Write each subnet's first and last device address.