Unit 2: Addresses and subnets · Lesson 2 of 7 · 16 min

Sizing subnets

Count host bits to work out how big a subnet is and where it ends.

mission

You are
The analyst helping the infrastructure team.
Situation
Two new teams need their own subnets: one with about 60 machines and one with 25. The infrastructure lead asks you to size them so nothing is wasted.
Goal
Work out how many hosts each prefix gives and where each subnet ends.
Hand in
The host count of a /26 and the broadcast of a /27.

Move the prefix and watch the split

00001010000101000000000000001011
Network
10.20.0.0/24
Mask
255.255.255.0
First host
10.20.0.1
Last host
10.20.0.254
Broadcast
10.20.0.255
Usable hosts
254
Amber bits name the network, grey bits number the hosts.
01

Halve a /24

Each extra prefix bit halves the subnet. Two addresses are always reserved: the network address and the broadcast.

analyst@net-lab
ipcalc -nb 10.10.0.0/25
Address:   10.10.0.0
Netmask:   255.255.255.128 = 25
Wildcard:  0.0.0.127
=>
Network:   10.10.0.0/25
HostMin:   10.10.0.1
HostMax:   10.10.0.126
Broadcast: 10.10.0.127
Hosts/Net: 126                   Class A, Private Internet

you should see 128 addresses, 126 usable.

Prefix length and size

  1. /24256 addresses, 254 hosts
  2. /25128 addresses, 126 hosts
  3. /2664 addresses, ? hosts
  4. /2732 addresses, 30 hosts
  5. /304 addresses, 2 hosts
Usable hosts are 2 to the power of the host bits, minus the network and broadcast addresses.
02

Let ipcalc split for you

-s takes the host counts you need and carves them out of a range, largest first.

analyst@net-lab
ipcalc -nb -s 60 25 10.40.0.0/24 | grep -E 'Requested|Network|Unused' -A1 | grep -vE '^--|HostMin'
Network:   10.40.0.0/24
1. Requested size: 60 hosts
Netmask:   255.255.255.192 = 26
Network:   10.40.0.0/26
2. Requested size: 25 hosts
Netmask:   255.255.255.224 = 27
Network:   10.40.0.64/27
Unused:
10.40.0.96/27

you should see 60 hosts fit a /26, 25 fit a /27, and the rest stays free.

defender tip Leave room to grow. Renumbering a subnet later means touching every firewall rule and monitoring check that names it.

03

Size a link between two routers

A /30 leaves two usable addresses, exactly enough for the two ends of a link.

analyst@net-lab
ipcalc -nb 10.99.0.0/30 | grep -E 'HostMin|HostMax|Hosts'
HostMin:   10.99.0.1
HostMax:   10.99.0.2
Hosts/Net: 2                     Class A, Private Internet

you should see Two hosts: 10.99.0.1 and 10.99.0.2.

04

Halve it again

Each extra prefix bit halves the size.

analyst@net-lab
ipcalc -nb 10.10.0.0/26 | grep -E 'Network|Broadcast|Hosts'
Network:   10.10.0.0/26
Broadcast: 10.10.0.63
Hosts/Net: 62                    Class A, Private Internet

you should see A /26 holds 62 hosts.

What a defender takes away

  1. 1Each prefix bit halves the subnet.
  2. 2Usable hosts are the addresses minus two.
  3. 3Size subnets from the hosts you need, then keep the spare space together.

Questions

0 of 2 solved

Answer each one from what you find on your lab machine.

  1. Show hint

    ipcalc -nb 10.20.0.0/26 and read Hosts/Net.

  2. Show hint

    ipcalc again.