IPv4 addressing · Fundamentals · Module 3
Choosing a prefix for a requirement · page 2 of 2
Show topologyHide topology
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
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).
Verify
R2’s two links
R2 has a /30 link toward R1 and a /31 link toward R4. How do its address lines tell them apart?
You can tell them apart by the last octet of each mask, 252 for a /30 and 254 for a /31. R2’s settings hold one address line for each of its four interfaces (Figure 3.3), and the line of the one without an address reads “no ip address”.
R2, the branch router, joined by one cable each to R1, the HQ router, above it, to the switch SW1 at its left and to R4, a branch router, under it. At R2’s end of each cable, the interface name on one side of the cable and the last octet of its address on the other: Et0/0 and .226 on the cable to R1; Et0/1 and .1 on the cable to SW1; Et0/2 and .228 on the cable to R4. A short stub at R2’s lower right, with no cable, ends beside the tag “fourth interface, no address”.
In show running-config | include ip address, each line with an address gives the address, then the mask.
Here every interface of R2 is as planned.
Tap a line, or “Not in the output”, then submit.
Find the line of the link that uses both addresses of its block.
R2#show running-config | include ip addressScroll sideways to see the whole output
R2 has a /30 toward R1, a /25 for LAN 1 and a /31 toward R4, and its fourth interface has none.
- The link toward R1 has 192.168.9.226 with 252, a /30. Two of its 4 addresses are hosts.
- Branch LAN 1 has 192.168.9.1 with 128, a /25.
- 192.168.9.228 is R2’s address.
255.255.255.254is 31 ones and 1 host bit, so 2 addresses, and on this point-to-point link both are host addresses. - The fourth interface, with no address.
show ip interface Ethernet0/2 | include Internet address shows R2’s interface toward R4.
R2#show ip interface Ethernet0/2 | include Internet address1 Internet address is 192.168.9.228/31
Scroll sideways to see the whole output
- The address, then the prefix length. /31 leaves one host bit, so the pair is .228 and .229.
R2 tests R4 at the other address of the pair.
R4 answers every test, so the two addresses of one /31 work as the link’s two ends.
R2#ping 192.168.9.229Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.229, timeout is 2 seconds:1!!!!!2Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
- Five exclamation marks, five replies.
Success rate is 100 percent, five of five.
The link from R1 to R2 is renumbered as a /31 to save two addresses, starting with R1’s end.
These interface lines on R1 renumber its end of the link.
R1#configure terminalEnter configuration commands, one per line. End with CNTL/Z.R1(config)#interface Ethernet0/21R1(config-if)#ip address 192.168.9.224 255.255.255.2542% Warning: use /31 mask on non point-to-point interface cautiouslyR1(config-if)#end
- This line sets the new address and mask, 192.168.9.224 with
255.255.255.254, a /31. Before the change this line readip address 192.168.9.225 255.255.255.252, a /30. - A warning, not a refusal.
Impact Changing an interface’s address stops the packets sent to its old address, and can briefly stop the others that use that interface.
Why warn, when a /31 already works on R2’s Ethernet link to R4? Cisco documents 31-bit prefixes for point-to-point WAN interfaces, and the warning calls R1’s Ethernet interface non point-to-point, so IOS cautions but still accepts the line.
R2’s end is then renumbered to .225 with the same mask.
R1 shows its address lines after the change.
R1#show running-config | include ip address ip address 192.168.8.1 255.255.255.192 ip address 192.168.8.65 255.255.255.1921 ip address 192.168.9.224 255.255.255.254 no ip address
Scroll sideways to see the whole output
- The renumbered link, with the address, then the mask.
R1 then tests R2 at .225 on the renumbered link.
R2 answers every test across the renumbered 192.168.9.224/31, where R1’s .224, the first address, is used as a host address.
R1#ping 192.168.9.225Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.225, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent, five of five.
Key idea
A mask ending in 252 marks a /30 link, with two of its four addresses used, and 254 marks a /31, with both used.
Troubleshoot
A link whose ends disagree
One end of a link was given the wrong prefix or the wrong pair. What do the routers show?
Both cases start from the plan, where the link from R1 to R2 is a /30 again, with R1 at .225 and R2 at .226, and the link from R2 to R4 is a /31.
| Check | Good | Broken |
|---|---|---|
Read both ends’ address and mask with show running-config | include ip address or show ip interface | the same mask on both ends | the masks differ |
| Work out each end’s subnet, its block, network and broadcast address | both ends in one block | one end’s address is outside the other end’s block |
| Check that each address is a host address of its block | between the network and the broadcast address, or on a /31 either of the pair | it is the network or the broadcast address |
Case 1 of 2.R1’s test of R2 gets no answer
Case 1 · Symptom
One day, R1 tests R2 on the link to the branch and gets no answer.
R1#ping 192.168.9.226Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.226, timeout is 2 seconds:1.....2Success rate is 0 percent (0/5)
- Five dots, so no replies.
Success rate is 0 percent, so no test was answered.
Case 1 · Command
Read R2’s address lines.
Case 1 · Output
R2#show running-config | include ip address1 ip address 192.168.9.226 255.255.255.254 ip address 192.168.9.1 255.255.255.128 ip address 192.168.9.228 255.255.255.254 no ip address
Scroll sideways to see the whole output
- Key line The address is the plan’s .226, but the mask ends in 254, a /31, not the plan’s 252.
Case 1 · How far it reaches
Does the fault reach beyond this link? R2 tests R4 on its other link.
R2#ping 192.168.9.229Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.229, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent, so R4 answers.
Case 1 · What it means
Figure 3.4 · Case 1 · R1’s /30 holds all four addresses, but R2’s /31 holds only .226 and .227, so R1’s .225 is outside it. R1 at the top and R2 under it, joined by a cable; beside the cable, a cross tagged “no answer”. Under them, the link’s four addresses as a strip: .224, “.225 R1”, “.226 R2” and .227. A bracket above all four cells reads “R1: /30”; a highlighted bracket below only the last two reads “R2: /31”.
- 254 is a /31, so R2’s subnet on this link is 192.168.9.226/31, only .226 and .227.
- R1 still has a /30, 192.168.9.224/30, with R2 inside it. But R1’s .225 is outside R2’s new subnet, so the two ends no longer share a subnet, and no answer comes back to R1.
- R2’s address matches the plan, but its mask does not. R2 still reaches R4, so R2 itself works and the problem is on this one link.
Case 1 · Fix
Give R2’s interface the plan’s mask again, 255.255.255.252, with the same address.
On R2, these configuration lines make the fix.
R2#configure terminalEnter configuration commands, one per line. End with CNTL/Z.1R2(config)#interface Ethernet0/02R2(config-if)#ip address 192.168.9.226 255.255.255.252R2(config-if)#end
- Picks R2’s interface toward R1.
- The plan address with the plan’s /30 mask.
Impact Changing an interface’s address stops the packets sent to its old address, and can briefly stop the others that use that interface.
Case 1 · Proof
R1 tests R2 again.
R1#ping 192.168.9.226Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.226, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent, so R2 answers again.
End of case 1. Solved: Both ends use a /30 again.
On the /31 link, you can work out the far end’s address from R2’s own.
Case 2 of 2.R2’s test of R4 gets no answer
Case 2 · Symptom
On another day, R2 tests R4 on the /31 link and gets no answer. R4’s end of this link is its interface Et0/0.
R2#ping 192.168.9.229Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.229, timeout is 2 seconds:1.....2Success rate is 0 percent (0/5)
- Five dots.
Success rate is 0 percent, so no test was answered.
Case 2 · Command
Run commands to narrow the cause, then choose it.
Choose the next command
Best next command:
R4# show running-config | include ip addressThe test fails toward R4: read R4’s own address line first and find its pair.R4#show running-config | include ip address ip address 192.168.9.230 255.255.255.254 ip address 192.168.9.193 255.255.255.224 no ip address no ip address
Scroll sideways to see the whole output
R4#show ip interface Ethernet0/0 | include Internet address Internet address is 192.168.9.230/31
R2#show running-config | include ip address ip address 192.168.9.226 255.255.255.252 ip address 192.168.9.1 255.255.255.128 ip address 192.168.9.228 255.255.255.254 no ip address
Scroll sideways to see the whole output
R2#ping 192.168.9.225Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.225, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
How to reason it out
Read both ends: R2’s lines are as planned, and R4’s reads .230 with 254.
Work out R4’s subnet: 192.168.9.230/31, the pair .230 and .231.
R2’s .228 is not in it, and .229, the address R2 tests, is no longer R4’s: the two ends no longer share a subnet, and no answer comes back to R2.
Answer to see what it means, the fix and the proof.
Case 2 · How far it reaches
Is R2 itself fine? It tests R1 on its other link.
R2#ping 192.168.9.225Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.225, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent, so R1 answers.
Case 2 · What it means
Figure 3.5 · Case 2 · R2’s /31 is .228 and .229, and R4’s is .230 and .231, the same prefix but not the same pair. R2 at the top and R4 under it, joined by a cable; beside the cable, a cross tagged “no answer”. Under them, four addresses as a strip: “.228 R2”, .229, “.230 R4” and .231. A bracket above the first two reads “R2: /31”; a highlighted bracket below the last two reads “R4: /31”.
- R4’s .230 starts the next pair, so R4’s subnet is 192.168.9.230/31, .230 and .231.
- Both ends use a /31, but not the same pair. The address R2 tests, .229, is no longer R4’s, and R2’s .228 is outside R4’s subnet, so no answer comes back to R2.
- R2’s own lines are as planned and R2 still reaches R1, so the fault lies on R4’s side.
Case 2 · Fix
Give R4 its plan address, 192.168.9.229, the other address of R2’s pair, with the same mask. Changing an interface’s address stops the packets sent to its old address, and can briefly stop the others that use that interface.
Case 2 · Proof
With R4 on its plan address, .229, every test from R2 gets an answer.
R2#ping 192.168.9.229Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.229, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent, so R4 answers.
End of case 2. Solved: Both ends are in one pair again, .228 and .229.
What both cases share follows once you have answered case 2.
Both cases
Key idea
Both ends of a link need the same prefix and the same block.
Check
On R1, the HQ router, with every interface as planned:
Tap a line, or “Not in the output”, then submit.
Find the line of the link that would save two addresses as a /31.
R1#show running-config | include ip addressScroll sideways to see the whole output
Read both outputs, then choose the most likely cause.
Symptom: R1’s test of R2 on the /30 link gets no answer. On R2:
R2#show ip interface Ethernet0/0 | include Internet address Internet address is 192.168.9.226/31
Scroll sideways to see the whole output
R2#ping 192.168.9.229Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.9.229, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
How to reason it out
R2 reports 192.168.9.226/31: the plan address, but a /31 where the link is a /30.
R2’s subnet is .226 and .227; R1’s .225 is not in it.
Summary
“Branch LAN 1 needs 100 hosts” at the top. Under it, three rows: 5 host bits hold 30 hosts and 6 hold 62, both “too few”; 7 hold 126, “fits”. Then “/25 · mask 255.255.255.128”. Then a link: “/30: 4 addresses, 2 hosts” and “/31: 2 addresses, both hosts”. At the foot, “LAN 1: /25 · a link: /30 or /31”.
- A need is a number of hosts per subnet or a number of subnets per block, and each decides the prefix in its own way.
- For H hosts, take the fewest host bits h with 2ʰ − 2 ≥ H, and the prefix is 32 − h (branch LAN 1, 100 hosts, /25).
- For N subnets, take the fewest subnet bits s with 2ˢ ≥ N, and the prefix is the block’s prefix plus s (HQ, 4 LANs, /26).
- A point-to-point link needs two host addresses: a /30 gives them out of 4, a /31 out of 2, where both are host addresses. In
show running-config | include ip addressthe mask octet tells them apart: 252 or 254. - Both ends of a link need the same prefix and the same block: a different mask (192.168.9.226/31) or the next pair of addresses leaves the ends in different subnets, and the test gets no answer.
Commands
show running-config | include ip addresseach configuration line that holds “ip address”; a last mask octet of 252 is a /30, 254 a /31.
show ip interface Ethernet0/2 | include Internet addressthe interface’s address with its prefix length; compare it with the other end’s.
ping 192.168.9.229a test of the other end of a link: the Success rate line says whether it answered.