Cisco switch: 802.1q trunk to router, aka router-on-a-stick

Contributor Icon Contributed by Al Banks  
Tag Icon Tagged: Cisco switch  

Connect a Cisco switch and router via 802.1q trunking. This configuration is known as a router-on-a-stick.


First, let’s start with the switch. VLAN 1 exists by default, so we’ll add a couple of other VLANs:

vlan 100
name data
state active

vlan 200
name data
state active

Now, let’s configure the switchport to connect to the router:
interface fastethernet 1/0/1
switchport trunk encapsulation dot1q
switchport mode trunk

Over to the router!

interface fastethernet 0/0
no ip address

interface fastethernet 0/0.1
encapsulation dot1q 1 native

interface fastethernet 0/0.100
encapsulation dot1q 100
ip address 192.168.100.1 255.255.255.0

interface fastethernet 0/0.200
encapsulation dot1q 200
ip address 192.168.200.1 255.255.255.0

At this point, workstations on VLAN 100 should be able to ping the 192.168.100.1 address, and workstations on VLAN 200 should be able to ping the 192.168.200.1 address.

If, for some reason, the native VLAN on the switchport is something other than 1, change the encapsulation statement on the router, or the trunk may not form.

 

15 Comments -


  1. Haitham said on December 14, 2008

    Hello, I wonder how to create a 802.1q interface in cisco 2600 router with ios ver c2600-i-mz_122-1?
    it has one interface Ethernet 0/0
    but I searched about encapsulation .1q commands and couldn’t find it.
    So i need your advice.
    Best Regards
    Dahab

  2. vtwin said on January 15, 2009

    You need fastEthernet interface.

  3. Dominusanubis said on January 19, 2009

    You have the wrong IOS, go to Cisco’s site and download this IOS….

    c2600-d-mz

  4. Dominusanubis said on January 19, 2009

    And no, you dont need a Fast Ethernet interface to do encapsulation.

  5. felix said on March 1, 2009

    its usuall not a good idea to use vlan 1 as your management vlan for security reasons.

    make sure to trunk the interface directly conecting the switch to the router.

  6. Bob said on April 6, 2009

    try using ISL as the encapsulation. And if the router has a AUX port you can get a dongle that will turn it into a ethernet/fast ethernet port

  7. felix said on June 20, 2009

    You do need FastEthernet interface. You cannot create a sub-interfaces from a regular Ethernet interface. So, you cannot use a router that doesn’t have a fastethernet interface in a router on a stick configuration

  8. toni said on June 30, 2009

    veryyyyyyyyyyyyyy good help

  9. Tony said on July 10, 2009

    Dude! Simplest explanation of VLAN and TRUNK’ing I have ever seen. Sweeeeet!

  10. Anonymous said on April 22, 2010

    good work, keep it up.

  11. Ace said on July 8, 2010

    omg :0

    Ive totally forgot encapsulation dot1q 1 native in sub

    thanQ

  12. Axiz said on September 28, 2010

    how about routing vlan 100 to vlan 200 what would be the config?

  13. Hhaa111 said on October 3, 2010

    I tried creating sub-interface on a regular ethernet interface and it does allow you to create.

    Interface IP-Address OK? Method Status Protocol
    Ethernet0/0 155.1.58.5 YES manual up up
    Ethernet0/0.1 unassigned YES unset up up
    Serial0/0 155.1.0.5 YES manual up up

  14. Markjunky said on July 29, 2011

    They are rotued on the router … ’show ip route’ on the router should show the two routes as connected. Hence, hosts on VLAN 100 should point to 192.168.100.1 as their gateway to VLAN 200, and hosts on VLAN 200 should point to 192.168.200.1 as their gateway to VLAN 100.

  15. simone1 said on January 10, 2012

    Is there a limit to amount of sub interfaces which can be created on one router fastethernet interface

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -