Inter-VLAN Routing (Router-on-a-Stick)
๐ What is Inter-VLAN Routing?
Inter-VLAN routing is the process of enabling communication between different VLANs using a Layer 3 device (router or L3 switch).
๐ Simple:
“Different VLANs can talk using a router.”
๐งช Lab Topology (Build in Cisco Packet Tracer)
Devices:
- 1 Switch (2960)
- 1 Router (2911)
- 4 PCs
๐น VLAN Plan
⚙️ Step 1: Assign IP Addresses
⚙️ Step 2: Create VLANs (Switch)
enable configure terminal vlan 10 name HR vlan 20 name IT
⚙️ Step 3: Assign Access Ports
interface fa0/1 switchport mode access switchport access vlan 10 interface fa0/2 switchport mode access switchport access vlan 20 interface fa0/3 switchport mode access switchport access vlan 10 interface fa0/4 switchport mode access switchport access vlan 20
⚙️ Step 4: Connect Switch → Router (IMPORTANT)
Use Straight-through cable
Connect:
Switch Fa0/23 → Router G0/0
⚙️ Step 5: Make Switch Port TRUNK
- interface fa0/23
- switchport mode trunk
⚙️ Step 6: Configure Router (CORE STEP ๐ฅ)
enable configure terminal interface g0/0 no shutdown interface g0/0.10 encapsulation dot1Q 10 ip address 192.168.10.254 255.255.255.0 interface g0/0.20 encapsulation dot1Q 20 ip address 192.168.20.254 255.255.255.0
๐งช Step 7: Test Connectivity
Same VLAN
ping 192.168.10.2
✔ Works
๐น Different VLAN (MAIN TEST)
From PC0:
ping 192.168.20.2
✔ Now it will WORK
Important Note:
Ethernet switches remember MAC addresses (Layer 2) to map devices to physical ports, while routers remember IP addresses (Layer 3) to map devices to logical network addresses. Switches use a temporary CAM table, while routers use DHCP leases to "remember" these assignments.
Key Takeaways:
Switch (MAC): Learns source MAC addresses from incoming frames and associates them with a port. These entries are temporary (typical 300-second aging timer).
Router (IP): Assigns IP addresses via DHCP to specific MAC addresses. These assignments ("leases") can be configured as static/persistent.
Function: Switches enable local network communication (same network), while routers manage traffic between different networks.
๐ What Happens Internally
- PC0 → sends packet to gateway (router)
- Router receives via VLAN 10 sub-interface
- Router routes to VLAN 20
- Sends back to PC3
๐ “Packet goes:
PC → Switch → Router → Switch → Destination”
๐ “Router performs Layer 3 decision”
⚠️ Common Mistakes
- ❌ Forgetting trunk on switch
- ❌ Missing encapsulation dot1Q
- ❌ Wrong default gateway
- ❌ Router interface shutdown
๐ง Key Concepts
- Router uses sub-interfaces
- Each VLAN = one sub-interface
- Router acts as gateway
๐ฏ Interview Questions
❓ What is Router-on-a-Stick?
๐ Using one physical router interface with multiple sub-interfaces for VLAN routing
❓ Why trunk is required?
๐ To carry multiple VLANs between switch and router
❓ Why ping was failing earlier?
๐ No Layer 3 routing between VLANs
๐ง Real-World Use
Used in:
- Small office networks
- Labs and training
- Basic enterprise setups












0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.