Calculating Subnets
Lab Objectives
- Learn how to calculate the network address, broadcast address, and first/last usable host for any IPv4 address + mask.
- Apply those calculations to subnets used in the base topology and verify router interface configuration.
- Practice configuring router interfaces and a Loopback to represent a VLAN gateway so you can verify your calculations with IOS commands.
ASCII Topology (BASE LAB TOPOLOGY — exact IPs shown)
[Internet]
203.0.113.1
|
R1 (Gateway)
Gi0/0: 10.10.10.1
Gi0/1: 10.10.20.1
Gi0/2: 10.10.30.1
/ | \
R2 R3 R4
Gi0/0: 10.10.10.2 | Gi0/0: 10.10.30.2
Gi0/1: 10.10.40.1 |
/ \ |
S1 S2 S3
/ \ | / \
PC1 PC2 PC3 PC4 PC5
IP Scheme (exact)
- 10.10.10.0/24 — R1-R2 link
- 10.10.20.0/24 — R1-R3 link
- 10.10.30.0/24 — R1-R4 link
- 10.10.40.0/24 — R2-S1 link
- 192.168.1.0/24 — VLAN 10 (Sales)
- 192.168.2.0/24 — VLAN 20 (Engineering)
- 192.168.3.0/24 — VLAN 30 (Management)
- 203.0.113.0/24 — Public/Internet simulation
Lab Tasks (Try It Yourself First!)
Complete these tasks WITHOUT looking at the solution below. Use
?andshowcommands to figure it out.
Task 1: Configure Router Interface IP addresses
Assign the exact IP addresses to R1, R2, R3 and R4 interfaces shown in the topology:
- R1 Gi0/0: 10.10.10.1/24, Gi0/1: 10.10.20.1/24, Gi0/2: 10.10.30.1/24
- R2 Gi0/0: 10.10.10.2/24, Gi0/1: 10.10.40.1/24
- R3 Gi0/0: 10.10.20.2/24
- R4 Gi0/0: 10.10.30.2/24 Do not change other parameters.
Task 2: Calculate subnet details (network, broadcast, usable hosts)
For each of these example host IPs and masks, calculate:
- Network address
- Broadcast address
- First usable host
- Last usable host
Use manual calculation or binary method (no IOS commands).
a) 192.168.1.57/26
b) 192.168.2.130/25
c) 192.168.3.5/29
Task 3: Configure a Loopback to represent VLAN 10 gateway and verify
Create Loopback0 on R2 and assign 192.168.1.1/24 (represents the VLAN 10 gateway). Verify the IP is present and reachable from R1 by displaying interface and route information.
Think About It: If VLAN 10 uses the /26 subnets in Task 2a, why would you choose /26 instead of /24 for a departmental VLAN in a real network? Consider address waste and broadcast domain size.
Lab Solution
Task 1 Solution: Configure Router Interface IP addresses
What we are doing: Setting the exact IPv4 addresses on router physical interfaces to match the lab topology so devices share the right L2/L3 networks. This is necessary because correct addressing ensures adjacency and reachability between routers and downstream networks.
! On R1
interface GigabitEthernet0/0
ip address 10.10.10.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/1
ip address 10.10.20.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/2
ip address 10.10.30.1 255.255.255.0
no shutdown
! On R2
interface GigabitEthernet0/0
ip address 10.10.10.2 255.255.255.0
no shutdown
!
interface GigabitEthernet0/1
ip address 10.10.40.1 255.255.255.0
no shutdown
! On R3
interface GigabitEthernet0/0
ip address 10.10.20.2 255.255.255.0
no shutdown
! On R4
interface GigabitEthernet0/0
ip address 10.10.30.2 255.255.255.0
no shutdown
What just happened:
- Each
interfacecommand selects the physical interface. ip address x.x.x.x 255.255.255.0assigns the IPv4 address and mask (here /24).no shutdownenables the interface so it can form adjacency and pass traffic. These steps matter because wrong IP or mask means devices will be on different networks and cannot communicate directly.
Verify:
show ip interface brief
Expected output excerpt (full lines shown for lab interfaces):
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 10.10.10.1 YES manual up up
GigabitEthernet0/1 10.10.20.1 YES manual up up
GigabitEthernet0/2 10.10.30.1 YES manual up up
Loopback0 unassigned YES manual administratively down down
(Repeat show ip interface brief on R2/R3/R4 to confirm their configured addresses.)
Tip: On a simulator/emulator physical link state may show "up up" only if both ends are configured. If the far side is missing, you'll see "up/down" — this is a clue to check the neighbor.
Task 2 Solution: Calculate subnet details
What we are doing: For each IP and prefix, we manually derive the network ID, broadcast, and usable host range. Understanding binary division of the host portion is essential — think of the mask as a divider that partitions the 32-bit address into network and host bits.
a) 192.168.1.57/26
- /26 = 255.255.255.192 => block size in last octet = 256 - 192 = 64
- Subnet blocks: 0, 64, 128...
- 57 lies in the 0–63 block.
- Network = 192.168.1.0
- Broadcast = 192.168.1.63
- First usable = 192.168.1.1
- Last usable = 192.168.1.62
b) 192.168.2.130/25
- /25 = 255.255.255.128 => block size = 128
- Blocks: 0–127, 128–255
- 130 lies in 128–255 block.
- Network = 192.168.2.128
- Broadcast = 192.168.2.255
- First usable = 192.168.2.129
- Last usable = 192.168.2.254
c) 192.168.3.5/29
- /29 = 255.255.255.248 => block size = 8
- Blocks: 0–7, 8–15, ...
- 5 lies in 0–7 block.
- Network = 192.168.3.0
- Broadcast = 192.168.3.7
- First usable = 192.168.3.1
- Last usable = 192.168.3.6
Why this matters in production: Choosing /26 instead of /24 lets you split a /24 into four smaller VLAN networks. That reduces broadcast domain size and preserves address space when you only need ~60 hosts per VLAN. Conversely, picking too-small a mask wastes administrative effort and can complicate routing.
Task 3 Solution: Configure Loopback0 on R2 as VLAN 10 gateway and verify
What we are doing: Create a Loopback on R2 with 192.168.1.1/24 to represent the VLAN 10 gateway. Loopbacks are logical interfaces always up/up and are useful for stable gateway addresses and testing.
! On R2
interface Loopback0
ip address 192.168.1.1 255.255.255.0
!
end
What just happened:
interface Loopback0creates a stable virtual interface.ip addressassigns the VLAN gateway address. Using a Loopback ensures the address won't go down with a physical link failure and is ideal for testing and routing protocols.
Verify:
show ip interface brief
Expected relevant output on R2:
Interface IP-Address OK? Method Status Protocol
Loopback0 192.168.1.1 YES manual up up
GigabitEthernet0/0 10.10.10.2 YES manual up up
GigabitEthernet0/1 10.10.40.1 YES manual up up
To verify reachability from R1 (assuming connectivity on the 10.10.10.0/24 link):
! From R1
ping 192.168.1.1
Expected ping success (sample):
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/5/10 ms
Troubleshooting Scenario
Scenario: R1 cannot ping 192.168.1.1
Symptom: Ping from R1 to 192.168.1.1 fails.
Your task: Find and fix the issue.
Hint: Check both addressing and mask on R2 Loopback and the R1-R2 link status.
Solution:
- Verify R2 Loopback address with
show ip interface brief. If Loopback is unassigned or has wrong mask, correct it:
interface Loopback0
ip address 192.168.1.1 255.255.255.0
- Verify R1 and R2 Gi0/0 are in same /24 and up:
show ip interface brief
If link down, ensure no shutdown on both ends and physical connectivity in emulator.
Verification Checklist
- R1 interfaces configured with 10.10.10.1/24, 10.10.20.1/24, 10.10.30.1/24
- R2 configured with 10.10.10.2/24 and Loopback0 192.168.1.1/24
- Manual subnet calculations for /26, /25, /29 match the answers above
- R1 can ping R2 Loopback0
Common Mistakes
| Symptom | Cause | Fix |
|---|---|---|
| Ping to Loopback fails | Loopback mask mistaken (e.g., /26 vs /24) | Reconfigure Loopback with correct mask ip address 192.168.1.1 255.255.255.0 |
| Interfaces show up/down | One side of link not configured or shutdown | no shutdown on both interfaces; check neighbor IPs |
| Wrong subnet calculation | Incorrect block size or not converting mask to decimal | Recompute: block = 256 - mask_octet; find containing block |
Important: Think of subnetting like dividing a cake — the mask decides the slice size. If you pick a slice (subnet) too big, you waste cake; pick too small and you may not feed everyone.
Challenge Task
Divide 192.168.1.0/24 into 8 equal subnets. For the subnet that contains host 192.168.1.210, identify network, broadcast, and usable host range. Then assign that gateway address as Loopback1 on R3 and verify end-to-end reachability from R4. (No step-by-step provided.)