DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

LAB: Subnetting with Router (2 Networks)

🧠 PART 1 β€” WHAT YOU BUILT

  • LEFT side β†’ Switch + PCs β†’ Subnet 1
  • RIGHT side β†’ Switch + PCs β†’ Subnet 2
  • Middle β†’ Router β†’ connects them

πŸ‘‰ This is real-world design


🧠 PART 2 β€” WHY SUBNETTING IS IMPORTANT

❌ Without subnetting (one big network)

  • Too many devices
  • Broadcast storms
  • Slow network
  • No security separation

βœ… With subnetting

You create smaller networks (subnets):

Benefit Explanation
Performance Less broadcast traffic
Security Can control access
Organization HR, IT, Finance separated
Scalability Easy to grow

πŸ‘‰ Example (your lab):

  • Subnet 1 = Office A
  • Subnet 2 = Office B
  • Router = gate between them

🧠 PART 3 β€” SUBNET DESIGN (VERY IMPORTANT)

We define:

Subnet 1 (LEFT)

Network: 192.168.1.0/24
Gateway: 192.168.1.1
Enter fullscreen mode Exit fullscreen mode

Subnet 2 (RIGHT)

Network: 192.168.2.0/24
Gateway: 192.168.2.1
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Explain /24

2^8 = 256

  • 8 bits for hosts
  • 256 IP addresses total
  • 254 usable

🧠 PART 4 β€” CONFIGURATION (STEP-BY-STEP)

πŸ”Ή 1. Configure Router

Open Router CLI:

enable
configure terminal

interface g0/0
ip address 192.168.1.1 255.255.255.0
no shutdown

interface g0/1
ip address 192.168.2.1 255.255.255.0
no shutdown
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 2. Configure PCs (VERY IMPORTANT)

LEFT PCs

PC IP Gateway
PC0 192.168.1.10 192.168.1.1
PC1 192.168.1.11 192.168.1.1
PC2 192.168.1.12 192.168.1.1

RIGHT PCs

PC IP Gateway
PC3 192.168.2.10 192.168.2.1
PC4 192.168.2.11 192.168.2.1
PC5 192.168.2.12 192.168.2.1

🧠 PART 5 β€” HOW IT WORKS (CRITICAL)

πŸ” Same Subnet Communication

Example:

PC0 β†’ PC1
Enter fullscreen mode Exit fullscreen mode

βœ” Goes through switch only
❌ Router NOT used


🌍 Different Subnet Communication

Example:

PC0 β†’ PC3
Enter fullscreen mode Exit fullscreen mode

Steps:

  1. PC0 sees β†’ destination is different subnet
  2. Sends packet to default gateway (router)
  3. Router checks routing table
  4. Router forwards to subnet 2
  5. PC3 receives

πŸ‘‰ THIS is the key concept:

Router = device that connects different networks


🧠 PART 6 β€” TESTING

πŸ”Ή Test same subnet

From PC0:

ping 192.168.1.11
Enter fullscreen mode Exit fullscreen mode

βœ” Should work


πŸ”Ή Test different subnet

ping 192.168.2.10
Enter fullscreen mode Exit fullscreen mode

βœ” Should work only if router configured correctly


🧠 PART 7 β€” WHAT HAPPENS IF NO ROUTER?

πŸ‘‰ β€œWhat if router is removed?”

Answer:

  • PC0 cannot reach PC3
  • Because different networks need routing

🧠 PART 8 β€” INTERVIEW LEVEL EXPLANATION

You can say:

Subnetting divides a large network into smaller logical networks to improve performance, security, and manageability. Devices within the same subnet communicate directly via Layer 2, while communication between subnets requires a Layer 3 device like a router.


πŸ§ͺ BONUS TASK

  1. Change subnet mask to /25
  2. Create 4 subnets
  3. Assign new IPs
  4. Test connectivity

🧠 WHAT IS BROADCASTING?

Broadcast = one device sends data to ALL devices in the network


πŸ” Example

PC1 β†’ ALL PCs in same network
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Real case (VERY IMPORTANT)

When PC1 doesn’t know MAC address:

It sends:

β€œWho has 192.168.1.20?”

πŸ‘‰ This is ARP broadcast


πŸ”Ή What happens

  • Switch receives frame
  • Sends it to ALL ports (same VLAN only)

πŸ’‘ Key rule

Broadcast stays inside the same subnet / VLAN


πŸ”₯ In your lab

  • VLAN 10 β†’ broadcast stays inside VLAN 10
  • VLAN 20 β†’ separate broadcast domain


🧠 WHAT IS MULTICASTING?

Multicast = one device sends data to a specific GROUP of devices


πŸ” Example

Server β†’ Only interested clients
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Real examples

  • Video streaming
  • Online classes
  • Stock market feeds

πŸ‘‰ Not everyone receives it β€” only subscribers


πŸ”Ή IP Range for Multicast

224.0.0.0 – 239.255.255.255
Enter fullscreen mode Exit fullscreen mode


🧠 WHAT IS UNICAST (IMPORTANT TOO)

Unicast = one-to-one communication


πŸ” Example

PC1 β†’ PC2
Enter fullscreen mode Exit fullscreen mode

βœ” Most common
βœ” Used in ping, web traffic, SSH



βš–οΈ DIFFERENCE (VERY CLEAR)

Type Meaning Example
Unicast 1 β†’ 1 PC β†’ Server
Broadcast 1 β†’ ALL ARP request
Multicast 1 β†’ Group Streaming


🧠 SIMPLE ANALOGY

  • Unicast β†’ Phone call
  • Broadcast β†’ Shouting in a room
  • Multicast β†’ Talking to a group in a meeting


πŸ”₯ WHY BROADCAST IS IMPORTANT (AND DANGEROUS)

βœ… Needed for:

  • ARP
  • DHCP discovery

❌ Problem:

Too many broadcasts =

πŸ‘‰ Network slowdown
πŸ‘‰ CPU overload
πŸ‘‰ β€œBroadcast storm”



🧠 HOW VLAN HELPS

πŸ‘‰ VLAN reduces broadcast

Instead of:

1 big network β†’ 1000 devices receive broadcast
Enter fullscreen mode Exit fullscreen mode

You get:

VLAN 10 β†’ 100 devices
VLAN 20 β†’ 100 devices
Enter fullscreen mode Exit fullscreen mode

βœ” Faster
βœ” Cleaner



🧠 HOW ROUTER HANDLES IT

πŸ‘‰ Router does NOT forward broadcast


Example:

  • PC in VLAN10 sends broadcast ❌ Router blocks it βœ” VLAN20 never receives it


🧠 MULTICAST IN REAL NETWORKS

Used when:

  • You don’t want broadcast (too heavy)
  • You don’t want multiple unicast (too expensive)

Example:

Instead of:

Server β†’ 100 users (100 separate streams)
Enter fullscreen mode Exit fullscreen mode

Multicast:

Server β†’ 1 stream β†’ group receives
Enter fullscreen mode Exit fullscreen mode

βœ” Efficient



πŸ”₯ INTERVIEW ANSWER (SHORT)

Broadcast is one-to-all communication within a subnet or VLAN and is used for operations like ARP. Multicast is one-to-many communication where data is sent only to a specific group of devices. Unlike broadcast, multicast is more efficient because it avoids sending data to unnecessary devices.

In your Packet Tracer:

  • ARP request = broadcast
  • Ping = unicast
  • VLAN = controls broadcast domain

πŸ”₯ FINAL LINE (MEMORIZE)

Broadcast sends data to all devices in a network, multicast sends data to a selected group, and unicast sends data to a single device.

🧠 PART 1 β€” HOW COMMUNICATION REALLY WORKS


πŸ”Ή 1. SAME NETWORK (NO VLAN)

Example:

PC1 (192.168.1.10) β†’ PC2 (192.168.1.20)
Enter fullscreen mode Exit fullscreen mode

What happens step-by-step:

  1. PC1 checks:
  • β€œIs 192.168.1.20 in my network?” βœ” YES
  1. PC1 sends ARP:

β€œWho has 192.168.1.20?”

  1. Switch:
  • Broadcasts to all ports
  1. PC2 replies with MAC

  2. Switch learns:

  • MAC β†’ Port mapping (MAC table)
  1. Data flows directly

πŸ‘‰ Key:

  • Uses MAC address
  • Switch works at Layer 2
  • Router NOT used

🧠 2. DIFFERENT NETWORK (SUBNET)

Example:

PC1 (192.168.1.10) β†’ PC3 (192.168.2.10)
Enter fullscreen mode Exit fullscreen mode

What happens:

  1. PC1 checks:
    ❌ β€œDifferent network”

  2. PC1 sends packet to:

Default Gateway (Router)
Enter fullscreen mode Exit fullscreen mode
  1. Router:
  • Removes Layer 2 frame
  • Checks IP (Layer 3)
  • Decides where to send
  1. Router forwards to subnet 2

πŸ‘‰ Key:

  • Uses IP address
  • Router is required

🧠 3. VLAN (WHY SWITCH BLOCKS)

Example:

  • PC1 β†’ VLAN 10
  • PC2 β†’ VLAN 20

What happens:

  1. PC1 sends ARP
  2. Switch checks VLAN
  3. ❌ Does NOT forward to VLAN 20

πŸ‘‰ VLAN = separate broadcast domain


🧠 FINAL RULE (MEMORIZE)

πŸ‘‰ Same VLAN β†’ Switch
πŸ‘‰ Different VLAN β†’ Router


πŸš€ PART 2 β€” FULL LAB (USING YOUR TOPOLOGY)


🎯 Goal

You will:

  • Create VLANs
  • Assign ports
  • Configure trunk
  • Configure router (inter-VLAN routing)
  • Enable DHCP
  • Add ACL security
  • Test everything

πŸ§ͺ STEP 1 β€” VERIFY TOPOLOGY

You already have:

  • PCs βœ”
  • Switch βœ”
  • Router βœ”

Make sure:

  • PCs connected to switch
  • Switch connected to router

πŸ§ͺ STEP 2 β€” SWITCH CONFIGURATION

Click Switch β†’ CLI:


πŸ”Ή Enter config mode

enable
configure terminal
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Create VLANs

vlan 10
name HR

vlan 20
name IT
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Assign Ports

Example (adjust to your ports):

interface fa0/1
switchport mode access
switchport access vlan 10

interface fa0/2
switchport mode access
switchport access vlan 10

interface fa0/3
switchport mode access
switchport access vlan 20

interface fa0/4
switchport mode access
switchport access vlan 20
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Configure Trunk (IMPORTANT)

Port connected to router:

interface fa0/24
switchport mode trunk
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ STEP 3 β€” ROUTER CONFIGURATION

Click Router β†’ CLI:


πŸ”Ή Enter config

enable
configure terminal
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Router-on-a-Stick

interface g0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0

interface g0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0

interface g0/0
no shutdown
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ This allows router to handle VLANs


πŸ§ͺ STEP 4 β€” DHCP CONFIG

ip dhcp pool HR
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1

ip dhcp pool IT
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή On PCs

  • Click PC
  • Desktop β†’ IP Configuration
  • Select DHCP

πŸ§ͺ STEP 5 β€” ACL (SECURITY)

🎯 Block HR β†’ IT

access-list 100 deny ip 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255
access-list 100 permit ip any any
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Apply ACL

interface g0/0.10
ip access-group 100 in
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ STEP 6 β€” TESTING


βœ… SAME VLAN

From VLAN10 PC:

ping 192.168.10.X
Enter fullscreen mode Exit fullscreen mode

βœ” Should work


❌ BLOCKED

From VLAN10:

ping 192.168.20.X
Enter fullscreen mode Exit fullscreen mode

❌ Should fail


βœ… ALLOWED

From VLAN20:

ping 192.168.10.X
Enter fullscreen mode Exit fullscreen mode

βœ” Should work


🧠 PART 3 β€” WHAT STUDENTS MUST UNDERSTAND


πŸ”Ή Switch Role

  • Forwards based on MAC
  • Works inside VLAN only

πŸ”Ή VLAN Role

  • Separates Layer 2 traffic
  • Creates isolated networks

πŸ”Ή Subnet Role

  • Defines IP structure
  • Enables routing

πŸ”Ή Router Role

  • Connects networks
  • Routes packets

πŸ”Ή DHCP Role

  • Assigns IP automatically

πŸ”Ή ACL Role

  • Controls traffic (security)

πŸ”₯ FINAL INTERVIEW ANSWER

Devices in the same VLAN communicate directly using Layer 2 switching. When devices are in different VLANs or subnets, communication requires a Layer 3 device such as a router. VLANs provide logical segmentation, subnetting provides IP structure, and routing enables communication between networks.

Top comments (0)