-->

  • Inter-VLAN Routing Router-on-a-Stick




     

    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.