Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Splitting a network into subnets

After this lesson: I can split a network into subnets.

50 min lesson3 commandsStatic routing lab: build routes on a small network in your browser

One office, three groups of devices

A small firm has one office and sixty devices. Tills, printers, staff laptops and guest phones all share one network.

The owner wants the tills kept apart from the guests. Before any cable moves, someone must cut one block of addresses into smaller blocks.

That cut is what this lesson teaches.

By the end of this lesson

Note

I can split a network into subnets.

Key words

WordWhat it meansExample
IP addressa number that names one device on a network10.0.12.77
Prefixthe number after the slash: how many bits name the network/24
Subnet maskthe prefix written as four numbers255.255.255.0
Subneta smaller network cut from a bigger one
Network addressthe first address of a block, which names the block itself
Broadcast addressthe last address of a block, used to speak to every device in it

The cells students fill in are left blank in this preview.

An address is thirty-two bits

An IPv4 address is 32 bits long. We write it as four numbers from 0 to 255, split by dots.

Each number is one byte. Computers work with the bits. People read the dotted form.

Worked example: one address in bits

PartNumberBits
First1000001010
Second000000000
Third1200001100
Fourth7701001101

The cells students fill in are left blank in this preview.

Read the lab's addresses

Command
netlab status

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

What the lab shows

Each machine lists its cables and an address with a prefix, such as 10.0.12.1/24.

Find the two addresses on the link between r1 and r2. They share the first 24 bits, so they are on one network.

The prefix splits network from device

The number after the slash is the prefix. It says how many bits, counted from the left, name the network.

The remaining bits name the device. In 10.0.12.77/24, the first 24 bits name the network and the last 8 bits name the device.

A longer prefix leaves fewer bits for devices.

Worked example: common prefixes

PrefixMaskAddressesUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/30255.255.255.25242

The cells students fill in are left blank in this preview.

Ask Python for a mask

Command
python3 -c "print(__import__('ipaddress').ip_network('10.0.12.0/24').netmask)"

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. The first names the network and the last is the broadcast address. Neither can go to a device, so a /24 holds 254 hosts.

Cutting a block into subnets

To cut a block, make the prefix longer. Each extra bit doubles the number of subnets and halves the size of each.

A /24 cut by two bits gives four /26 subnets. Each holds 64 addresses.

The new networks start at multiples of 64: 0, 64, 128 and 192.

Worked example: four subnets

NetworkFirst hostLast hostBroadcast
192.168.10.0/26192.168.10.1192.168.10.62192.168.10.63
192.168.10.64/26192.168.10.65192.168.10.126192.168.10.127
192.168.10.128/26192.168.10.129192.168.10.190192.168.10.191
192.168.10.192/26192.168.10.193192.168.10.254192.168.10.255

The cells students fill in are left blank in this preview.

Let Python cut the block

Command
python3 -c "print(list(__import__('ipaddress').ip_network('192.168.10.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.

Going further: subnets of different sizes

Real groups are rarely the same size. Cut 192.168.20.0/24 for 60 tills, 25 staff laptops and 10 guest phones.

Give the biggest group its block first, then the next biggest, each at the next free multiple of its size. Write the network, the first host, the last host and the broadcast for each.

Check every row with your calculate function, then say how many addresses are left over.

About this lab and its source: Static routing lab: build routes on a small network in your browser

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.