Back to Course
Practical

Practical 5: Subnetting a Class B Network

Calculate 8 subnets, build in Packet Tracer, and verify connectivity

🌐 Introduction to Networks 🛠️ Packet Tracer 👤 Reza Farashahi

Imagine a university campus with departments like Engineering, Business, Health Sciences, IT, Student Services, Administration, the Library, and a Research Lab. Putting every device — thousands of computers, printers, and phones — on a single flat network would cause massive broadcast traffic, make troubleshooting a nightmare, and leave no way to isolate sensitive data (e.g. student records from the public Wi-Fi).

Subnetting solves this by dividing one large network into smaller, manageable segments — one per department. Each subnet gets its own broadcast domain, which reduces congestion, improves security (you can apply firewall rules between subnets), and makes it much easier to locate and fix problems. This is exactly how real enterprise and campus networks are designed.

In this practical you will subnet a Class B network into 8 subnets — one for each department. You will calculate the network address, broadcast address, and valid host range for every subnet. Then you will build the network in Packet Tracer using VLANs and a router-on-a-stick configuration, and verify connectivity with ping.

📝 Task 1 — Subnet Calculation

You have been assigned the Class B network:

Step 1 — Determine bits to borrow

How many host bits must you borrow to create at least 8 subnets?

Step 2 — New subnet mask

Step 3 — Hosts per subnet

Work out the following from the /19 subnet mask:

QuestionYour Answer
Remaining host bits
Total addresses per subnet (2?)
Usable hosts per subnet (2? − 2)

Step 4 — Block size

Step 5 — Complete the subnet table

Fill in the details for each of the 8 subnets.

Subnet Network Address First Usable Host Last Usable Host Broadcast Address
1
2
3
4
5
6
7
8

📦 Task 2 — Build the Topology in Packet Tracer

Create the following network in Packet Tracer. We will use a Router-on-a-Stick design: one physical cable carries traffic for all 8 subnets using VLANs (Virtual LANs).

What is a VLAN? A VLAN lets you split one physical switch into multiple isolated virtual networks. Devices in different VLANs cannot communicate directly — they need a router, just like separate physical networks. Each VLAN represents one of our 8 subnets.

Equipment

Cabling

  1. Place the Router at the top of the workspace.
  2. Place the Switch below the router.
  3. Connect the router GigabitEthernet0/0 to the switch GigabitEthernet0/1 using a Copper Straight-Through cable.
  4. Arrange 16 PCs in 8 pairs below the switch (label them PC1–PC16).
  5. Connect each PC (FastEthernet0) to the switch using Copper Straight-Through cables:
    • PC1 → Switch Fa0/1  |  PC2 → Switch Fa0/2
    • PC3 → Switch Fa0/3  |  PC4 → Switch Fa0/4
    • PC5 → Switch Fa0/5  |  PC6 → Switch Fa0/6
    • PC7 → Switch Fa0/7  |  PC8 → Switch Fa0/8
    • PC9 → Switch Fa0/9  |  PC10 → Switch Fa0/10
    • PC11 → Switch Fa0/11  |  PC12 → Switch Fa0/12
    • PC13 → Switch Fa0/13  |  PC14 → Switch Fa0/14
    • PC15 → Switch Fa0/15  |  PC16 → Switch Fa0/16
Tip: Arrange each pair of PCs in a column below the switch and label them by subnet (e.g. “Subnet 1: PC1, PC2”) to keep the diagram clean.

🔧 Task 3 — Configure the Switch

Click on the Switch, go to the CLI tab, and paste the following configuration. This creates 8 VLANs (one per subnet), assigns PC ports to the correct VLAN, and sets up a trunk link to the router.

Part A — Enter privileged mode & global configuration

enable
configure terminal
hostname SubnetSwitch

Part B — Create VLANs

We create 8 VLANs — one for each subnet. A VLAN (Virtual LAN) logically separates ports on the same physical switch into isolated networks. Devices in VLAN 10 cannot talk to devices in VLAN 20 without going through the router, just as if they were on completely separate switches.

vlan 10
 name Subnet_1
vlan 20
 name Subnet_2
vlan 30
 name Subnet_3
vlan 40
 name Subnet_4
vlan 50
 name Subnet_5
vlan 60
 name Subnet_6
vlan 70
 name Subnet_7
vlan 80
 name Subnet_8

Part C — Assign ports to VLANs (access mode)

Each pair of PCs is plugged into two switch ports. We put those ports in access mode and assign them to the correct VLAN. An access port belongs to exactly one VLAN and strips the VLAN tag before sending frames to the PC (the PC never knows it is on a VLAN).

interface range FastEthernet0/1-2
 switchport mode access
 switchport access vlan 10
!
interface range FastEthernet0/3-4
 switchport mode access
 switchport access vlan 20
!
interface range FastEthernet0/5-6
 switchport mode access
 switchport access vlan 30
!
interface range FastEthernet0/7-8
 switchport mode access
 switchport access vlan 40
!
interface range FastEthernet0/9-10
 switchport mode access
 switchport access vlan 50
!
interface range FastEthernet0/11-12
 switchport mode access
 switchport access vlan 60
!
interface range FastEthernet0/13-14
 switchport mode access
 switchport access vlan 70
!
interface range FastEthernet0/15-16
 switchport mode access
 switchport access vlan 80

Part D — Configure the trunk link to the router

The uplink from the switch to the router must carry traffic for all 8 VLANs over a single cable. We set this port to trunk mode. A trunk port tags every outgoing frame with its VLAN ID (using the 802.1Q standard) so the router knows which subnet the frame belongs to.

interface GigabitEthernet0/1
 switchport mode trunk

Part E — Save the configuration

end
write memory
Access vs Trunk summary: An access port carries traffic for a single VLAN (connects to PCs). A trunk port carries traffic for all VLANs over one cable (connects to the router). Without the trunk, the router would need a separate physical cable for every VLAN.

🖧 Task 4 — Configure the Router

Click on the Router, go to the CLI tab, and enter the following configuration. This creates 8 sub-interfaces on a single physical port — one per VLAN/subnet — each acting as the default gateway for its subnet.

Part A — Enter privileged mode & bring up the physical interface

enable
configure terminal
hostname SubnetRouter
!
interface GigabitEthernet0/0
 no shutdown

Part B — Create sub-interfaces (one per VLAN)

A sub-interface is a logical division of a physical interface. The router uses sub-interfaces to handle traffic from different VLANs on the same physical cable — this is the “router-on-a-stick” design. Each sub-interface needs two things:

  1. VLAN encapsulation — tells the router which VLAN tag to look for.
  2. IP address — becomes the default gateway for all PCs in that subnet.
interface GigabitEthernet0/0.10
 encapsulation dot1Q 10
 ip address 172.16.0.1 255.255.224.0
!
interface GigabitEthernet0/0.20
 encapsulation dot1Q 20
 ip address 172.16.32.1 255.255.224.0
!
interface GigabitEthernet0/0.30
 encapsulation dot1Q 30
 ip address 172.16.64.1 255.255.224.0
!
interface GigabitEthernet0/0.40
 encapsulation dot1Q 40
 ip address 172.16.96.1 255.255.224.0
!
interface GigabitEthernet0/0.50
 encapsulation dot1Q 50
 ip address 172.16.128.1 255.255.224.0
!
interface GigabitEthernet0/0.60
 encapsulation dot1Q 60
 ip address 172.16.160.1 255.255.224.0
!
interface GigabitEthernet0/0.70
 encapsulation dot1Q 70
 ip address 172.16.192.1 255.255.224.0
!
interface GigabitEthernet0/0.80
 encapsulation dot1Q 80
 ip address 172.16.224.1 255.255.224.0
Why .1 for the gateway? It is a common convention to use the first usable host address (.1) in each subnet as the router’s gateway address. This makes it easy for network administrators to remember — the gateway is always the “.1” address.

The same pattern repeats for all 8 sub-interfaces. Each one uses the next subnet’s first address (172.16.32.1, 172.16.64.1, … 172.16.224.1) and maps to the corresponding VLAN (20, 30, … 80).

Part C — Save the configuration

end
write memory
How inter-VLAN routing works: When PC1 (VLAN 10) pings PC3 (VLAN 20), the frame goes: PC1 → Switch (strips VLAN tag) → Switch trunk (adds VLAN 10 tag) → Router sub-interface .10 → Router routes to sub-interface .20 → Switch trunk (VLAN 20 tag) → Switch access port → PC3. The router is doing all the work of moving traffic between VLANs.

🔢 Task 5 — Configure PC IP Addresses

Assign a static IP address, subnet mask, and default gateway to each PC. The gateway is the router sub-interface IP for that subnet.

PC Subnet IP Address Subnet Mask Default Gateway Switch Port
PC11172.16.0.2255.255.224.0172.16.0.1Fa0/1
PC21172.16.0.3255.255.224.0172.16.0.1Fa0/2
PC32172.16.32.2255.255.224.0172.16.32.1Fa0/3
PC42172.16.32.3255.255.224.0172.16.32.1Fa0/4
PC53172.16.64.2255.255.224.0172.16.64.1Fa0/5
PC63172.16.64.3255.255.224.0172.16.64.1Fa0/6
PC74172.16.96.2255.255.224.0172.16.96.1Fa0/7
PC84172.16.96.3255.255.224.0172.16.96.1Fa0/8
PC95172.16.128.2255.255.224.0172.16.128.1Fa0/9
PC105172.16.128.3255.255.224.0172.16.128.1Fa0/10
PC116172.16.160.2255.255.224.0172.16.160.1Fa0/11
PC126172.16.160.3255.255.224.0172.16.160.1Fa0/12
PC137172.16.192.2255.255.224.0172.16.192.1Fa0/13
PC147172.16.192.3255.255.224.0172.16.192.1Fa0/14
PC158172.16.224.2255.255.224.0172.16.224.1Fa0/15
PC168172.16.224.3255.255.224.0172.16.224.1Fa0/16

Configure each PC

  1. Click on the PC → Desktop tab → IP Configuration.
  2. Select Static.
  3. Enter the IPv4 Address, Subnet Mask, and Default Gateway from the table above.
  4. Close the window and repeat for all 16 PCs.
Important: Make sure you set the Default Gateway on every PC. Without it, PCs in different subnets will not be able to communicate through the router.

📡 Task 6 — Verify Connectivity

A — Ping within the same subnet

Open the Command Prompt on PC1 and ping PC2 (same subnet):

ping 172.16.0.3

This should succeed immediately — both PCs are in the same VLAN and do not need the router.

B — Ping across different subnets

From PC1 (Subnet 1), ping PC3 in Subnet 2:

ping 172.16.32.2

This traffic goes: PC1 → Switch → Router (routes between VLANs) → Switch → PC3.

C — Test more cross-subnet pings

  1. PC5 → PC11: ping 172.16.160.2 (Subnet 3 → Subnet 6)
  2. PC7 → PC15: ping 172.16.224.2 (Subnet 4 → Subnet 8)
  3. PC16 → PC1: ping 172.16.0.2 (Subnet 8 → Subnet 1)

All pings should return successful replies.

D — Verify on the Router

On the router CLI, run:

show ip interface brief

You should see all 8 sub-interfaces with status up/up and their correct IP addresses.

Troubleshooting: If a ping fails:
  • Check the PC’s IP, mask, and gateway with ipconfig
  • Verify the PC is connected to the correct switch port
  • On the switch CLI, run show vlan brief to confirm port-to-VLAN mapping
  • On the router CLI, run show ip interface brief to confirm sub-interfaces are up

💬 Reflection Questions

  1. Why did we borrow 3 bits and not 2 or 4?
  2. What would change if you needed 16 subnets instead of 8?
  3. Can PC1 (172.16.0.2) communicate with PC3 (172.16.32.2) without the router? Why or why not?
  4. What is the purpose of the encapsulation dot1Q command on the router sub-interfaces?
  5. How many usable host addresses does each /19 subnet provide? Is this efficient for a network with only 2 devices per subnet?
  6. If you changed the subnet mask to /21, how many subnets would you have and how many hosts per subnet?

📋 Summary

In this practical you have:

Tip: Save your Packet Tracer file — you may extend this network in future practicals.