xkonekt
Language: EN
  • English
  • Türkçe
  • Español, Coming soon
  • Português, Coming soon
  • Deutsch, Coming soon
  • Français, Coming soon

IPv4 addressing · Fundamentals · Module 1

Borrowing host bits: masks beyond /8, /16, /24

Show topologyHide topology
R3routerH1hostR1HQ routerR2branch routerSW1switchR4branch routerSW2switch192.168.8.0/26192.168.8.64/26192.168.9.224/30192.168.9.228/31192.168.9.0/25192.168.9.192/27

Interfaces and addresses · Et = Ethernet. LAN C, LAN D and branch LAN 2 are planned and not cabled yet.

  • 192.168.8.0/26 · LAN AR1 Et0/0 192.168.8.1H1 eth0 192.168.8.10
  • 192.168.8.64/26 · LAN BR1 Et0/1 192.168.8.65R3 Et0/0 192.168.8.126
  • 192.168.9.224/30R1 Et0/2 192.168.9.225R2 Et0/0 192.168.9.226
  • 192.168.9.228/31R2 Et0/2 192.168.9.228R4 Et0/0 192.168.9.229
  • 192.168.9.0/25 · branch LAN 1 · SW1R2 Et0/1 192.168.9.1no other device yet
  • 192.168.9.192/27 · branch LAN 3 · SW2R4 Et0/1 192.168.9.193no other device yet
Topology · R1 joins HQ’s LAN A and LAN B and the link to the branch; the branch block is split into LANs and links of different sizes, and R2 and R4 hold the branch LANs.

Device icons joined by plain cables, each cable labeled with its subnet. Down the middle, top to bottom: R3, a router; R1, the HQ router; R2, the branch router; R4, a branch router; and the switch SW2. R3 is cabled to R1 (192.168.8.64/26), R1 to R2 (192.168.9.224/30), R2 to R4 (192.168.9.228/31) and R4 to SW2 (192.168.9.192/27). At the upper left, the host H1, a laptop, is cabled down from its base to R1 (192.168.8.0/26). Left of R2, the switch SW1 is cabled across to it (192.168.9.0/25).

What subnetting is

One block, several networks

HQ has one block, 192.168.8.0/24, a run of addresses in a row, and needs four separate LANs, local networks inside HQ. How do you make four?

The /24 mask leaves the last octet as the host part, so 192.168.8.0/24 is one network of 256 addresses.

Why is one network not enough? Every device in a network receives that network’s broadcasts, and all of them share one address range. HQ wants four LANs kept apart, each with its own range, joined by its router, R1.

A longer mask does it. The line between the network part and the host part moves right, and the host bits it borrows give each smaller network its own number. Each is a subnet, a network made from part of a larger block by making its mask longer, and cutting a block this way is subnetting. A subnet’s address then reads as three fields: the network, the subnet and the host.

HQ cuts its block into four subnets (Figure 1.1). The block is private, since it lies in 192.168.0.0 to 192.168.255.255, a range used inside an organization.

192.168.8.0/24 · one network256 addresses/26LAN ALAN BLAN CLAN D.0.64.128.192R1 · H1R1 · R3plannedplanned
Figure 1.1 · One /24 block becomes four /26 subnets. LAN A and LAN B are in use, LAN C and LAN D planned; LAN B joins R1 and R3.

A bar labeled “256 addresses” under the title “192.168.8.0/24 · one network”. An arrow marked /26 runs down to a row of four equal boxes: LAN A and LAN B as solid boxes, LAN B highlighted; LAN C and LAN D as one dashed outline split in two. Under the boxes, where each subnet starts: .0, .64, .128 and .192. Under those, what uses each: R1 and H1, R1 and R3, planned, planned.

Each subnet is a quarter of the block: 64 addresses. LAN A starts at .0, LAN B at .64, and so on. R1 has one interface in LAN A and one in LAN B.

Subnetting makes no new addresses. Add up the four LANs and you get the same 256, and in each LAN two of its addresses, its network address and its broadcast address, go to no device.

Four subnets take 2 bits from the host part, so HQ’s mask grows from /24 to /26. It ends two bits into the fourth octet, while /8, /16 and /24 end at an octet’s edge.

After subnetting 192.168.8.0/24 into four LANs, how many addresses does HQ have in all?

How it works

Borrowing bits

The mask’s ones mark the network part. What happens when you add ones to it?

Make HQ’s /24 mask one bit longer and the leftmost host bit joins the network side. That bit can be 0 or 1, so one network becomes two.

Bits the mask takes over this way number the subnets, so they are the subnet bits. They are taken from the left of the host part, next to the network part, because a mask’s ones must all come first, with no gap.

The bits still on the host side number the devices inside each subnet, so they are the host bits.

A second bit makes 4 and a third 8, so n subnet bits make 2ⁿ subnets, and h host bits make 2ʰ addresses in each subnet. Each borrowed bit doubles the subnets and halves the addresses in each.

Not every address of a subnet can go to a device. The all-zeros value names the subnet itself, and the all-ones value is its broadcast address. So the host count, the number of addresses a subnet can give to devices, is 2ʰ − 2.

On a point-to-point link, a link with exactly two ends, a /31 keeps no address back, an exception to the 2ʰ − 2 rule.

Step through Figure 1.2 to watch HQ’s block split into 2 subnets with one borrowed bit and 4 with two.

Step 1 of 7

mask, last octet/24000000001286432168421host bits: all eightoctet = 0one network · 256 addresses

With /24, the whole last octet of the mask is zeros: eight host bits. HQ’s block, 192.168.8.0/24, is one network of 256 addresses.

Step 2 of 7

mask, last octet/25100000001286432168421host bits: 7subnetbits: 1octet = 1282 subnets · 128 addresses

Borrow one bit. The leftmost host bit becomes a mask bit, so the octet is 128 and the prefix length is /25, which engineers often call just the prefix. This first subnet bit can be zero or one, so the block splits into two subnets of 128 addresses.

Step 3 of 7

mask, last octet/26110000001286432168421host bits: 6subnetbits: 2octet = 1924 subnets · 64 addresses

Borrow a second bit. The octet is 11000000, worth 192, and the prefix is /26. Two bits give four subnets of 64 addresses: one for each of HQ’s four LANs.

Step 4 of 7

mask, last octet/26110000001286432168421host bits: 6subnetbits: 2octet = 1924 subnets · 64 addresses · 62 hosts

Two subnet bits leave six host bits, 64 addresses in each subnet, of which 62 can go to devices.

Next, borrow a third bit: the prefix becomes /27. How many subnets, and how many hosts in each?

  • 8 subnets, 30 hosts each. (Correct): Three subnet bits make 2³ = 8 subnets. Five host bits leave 32 addresses in each, and two of them are kept back: 30 hosts.
  • Six subnets, 32 hosts each.: A borrowed bit doubles the subnets rather than adding two, so four become 8. The host figure also counts two addresses that go to no device.
  • 8 subnets, 32 hosts each.: That counts the subnet’s own address and its broadcast address as hosts.
  • 3 subnets, 62 hosts each.: 3 counts the borrowed bits, not the subnets. And 62 is the host count of a /26 subnet, which is twice the size of a /27 one.

Step 5 of 7

mask, last octet/27111000001286432168421host bits: 5subnetbits: 3octet = 2248 subnets · 32 addresses · 30 hosts

With a third bit the octet is 224 and the prefix is /27. The subnets double again and halve in size: 8 subnets of 32 addresses, 30 hosts each. HQ needs four LANs, each as large as possible, so it borrows only the two bits that make four: /26.

Step 6 of 7

mask, last octet/26110000001286432168421host bits: 6subnetbits: 2octet = 192.64/264 subnets · 64 addresses · 62 hostsR1 Et0/1 · 192.168.8.65255.255.255.192 = /26

Back at /26, the third bit is a host bit again. R1’s interface in LAN B, the second subnet, carries this mask, 255.255.255.192, and R1 reports it as /26.

Step 7 of 7

mask, last octet/26110000001286432168421host bits: 6subnetbits: 2octet = 192.64/264 subnets · 64 addresses · 62 hostsR1 Et0/1 · 192.168.8.65255.255.255.192 = /26

Borrowed bits number the subnets; the bits left number the hosts. HQ borrows two bits and gets four LANs of 62 hosts each.

Step 1 of 7

At the top, “mask, last octet” and the prefix: /24, then /25, /26, /27 and back to /26. Under it, eight cells for the eight bits of the mask’s last octet, all 0 at first, with their place values under them, 128 down to 1. Step by step the first, second and third cells turn to 1, and the octet’s value grows from 0 to 128, 192 and 224. A line under the cells marks the host bits, eight, then seven, six and five; from the first borrowed bit on, a second line marks the subnet bits. Under that, a bar for HQ’s block: one piece of 256 addresses, then two, four and eight pieces, with a count line under the bar. At step 6 the octet is back to two ones and the bar to four pieces, the second one, .64/26, is highlighted, and a card at the foot reads “R1 Et0/1 · 192.168.8.65, 255.255.255.192 = /26”.

Figure 1.2 · Each bit the mask borrows from the host part doubles the subnets and halves their size; HQ borrows two and gets four.With /24, the whole last octet of the mask is zeros: eight host bits. HQ’s block, 192.168.8.0/24, is one network of 256 addresses.Borrow one bit. The leftmost host bit becomes a mask bit, so the octet is 128 and the prefix length is /25, which engineers often call just the prefix. This first subnet bit can be zero or one, so the block splits into two subnets of 128 addresses.Borrow a second bit. The octet is 11000000, worth 192, and the prefix is /26. Two bits give four subnets of 64 addresses: one for each of HQ’s four LANs.Two subnet bits leave six host bits, 64 addresses in each subnet, of which 62 can go to devices.With a third bit the octet is 224 and the prefix is /27. The subnets double again and halve in size: 8 subnets of 32 addresses, 30 hosts each. HQ needs four LANs, each as large as possible, so it borrows only the two bits that make four: /26.Back at /26, the third bit is a host bit again. R1’s interface in LAN B, the second subnet, carries this mask, 255.255.255.192, and R1 reports it as /26.Borrowed bits number the subnets; the bits left number the hosts. HQ borrows two bits and gets four LANs of 62 hosts each.
Why does a /26 subnet hold 62 hosts and not 64?

/26 counts the ones in the mask, not hosts or subnets. HQ’s block at /26 has 4 subnets of 62 hosts.

Key idea

n borrowed bits make 2ⁿ subnets; h host bits leave 2ʰ addresses and 2ʰ − 2 hosts in each.

Masks that end inside an octet

With one, two, three or more borrowed bits, which numbers can a mask octet hold?

Each borrowed bit adds the next place value to the octet: 128, then 64, then 32. So the octet grows in steps, 128, 192, 224 and so on. Split with these masks, a /24 block makes 2 subnets at /25, 4 at /26 and 8 at /27, doubling with each bit.

Masks that split a /24 block
PrefixMaskHosts each
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522

The same values appear in any octet. /20, for example, borrows four bits from a /16, so its mask is 255.255.240.0, with 240 in the third octet.

Why only these steps? The mask must be left contiguous, with all its ones first and no gap. So the ones of a mask octet fill its leftmost bits and the rest are zeros, and a mask octet can hold only 128, 192, 224, 240, 248, 252, 254 or 255, or 0.

For /26 the two extra ones go in the fourth octet, which gives 255.255.255.192. The same 192 in the third octet makes 255.255.192.0, a /18.

On R1, the command show running-config | section interface Ethernet0/1 prints only the part of the settings for its interface toward LAN B.

R1 stores the mask in dotted form: 255.255.255.192.

Output · IOS XE 17.18.2
R1#show running-config | section interface Ethernet0/1interface Ethernet0/11 ip address 192.168.8.65 255.255.255.192
  1. The address, then the mask. The last octet, 192, is 11000000, two borrowed bits.

show ip interface Ethernet0/1 | include Internet address shows how R1 itself reports the same interface.

R1 counts the ones for you: /26.

Output · IOS XE 17.18.2
R1#show ip interface Ethernet0/1 | include Internet address1  Internet address is 192.168.8.65/26
  1. The prefix length, /26, is the 24 ones of three octets of 255 and two more.

R1 stores 255.255.255.192 but reports /26. Neither output shows how one turns into the other, so you count the ones yourself.

Move the prefix and watch the subnets and their hosts change.

/26: 4 subnets of 64 addresses, 62 hosts each

Prefix /26
Subnet 2 of 4
Network address
192.168.8.64
First host
192.168.8.65
Last host
192.168.8.126
Broadcast address
192.168.8.127

Marked address: 192.168.8.65

The subnets of 192.168.8.0/24 at /26
SubnetNetwork addressFirst hostLast hostBroadcast address
1.0.1.62.63
2.64.65.126.127
3.128.129.190.191
4.192.193.254.255

Suppose HQ’s needs change and it wants at least 6 LANs from the same block, each as large as possible.

Set the prefix, then submit it.

/25: 2 subnets of 128 addresses, 126 hosts each

Prefix /25
Subnet 1 of 2
Network address
192.168.8.0
First host
192.168.8.1
Last host
192.168.8.126
Broadcast address
192.168.8.127

Task 1 of 1

Split 192.168.8.0/24 into at least 6 subnets, with as many hosts in each as possible.

The subnets of 192.168.8.0/24 at /25
SubnetNetwork addressFirst hostLast hostBroadcast address
1.0.1.126.127
2.128.129.254.255

Task 1 of 1 Split 192.168.8.0/24 into at least 6 subnets, with as many hosts in each as possible.

Answer

/27

Two borrowed bits give only four subnets, so a third is needed: 8 subnets, at least 6. A fourth bit would make even more, but each would be smaller. So /27, with 30 hosts in each.

Key idea

A mask octet holds only 128, 192, 224, 240, 248, 252, 254 or 255 (or 0). Each step borrows one more bit.

Use the rule: three octets of all ones, then the octet that holds the borrowed bits.

For /28, the mask’s last octet is 11110000 (given). In dotted form, the whole mask is …?