Cisco Switch: 802.1q Trunk to Router (a.k.a. Router-on-a-Stick)

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


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

vlan 100
name data
state active

vlan 200
name data
state active

Now, we will configure the switchport to connect to the router:
interface fastethernet 1/0/1
switchport trunk encapsulation dot1q
switchport mode trunk

Now, we will move 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 one (1), change the encapsulation statement on the router, or the trunk may not form.

The Conversation

Follow the reactions below and share your own thoughts.

19 Responses to “Cisco Switch: 802.1q Trunk to Router (a.k.a. Router-on-a-Stick)”

  1. December 14, 2008 at 10:52 pm, Haitham said:

    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

    Reply

    • January 15, 2009 at 12:50 am, vtwin said:

      You need fastEthernet interface.

      Reply

    • January 19, 2009 at 8:55 am, Dominusanubis said:

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

      c2600-d-mz

      Reply

      • January 19, 2009 at 8:56 am, Dominusanubis said:

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

        Reply

        • June 20, 2009 at 12:35 am, felix said:

          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

          Reply

    • April 06, 2009 at 8:37 pm, Bob said:

      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

      Reply

  2. March 01, 2009 at 2:24 am, felix said:

    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.

    Reply

  3. June 30, 2009 at 3:22 pm, toni said:

    veryyyyyyyyyyyyyy good help

    Reply

  4. July 10, 2009 at 9:39 pm, Tony said:

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

    Reply

  5. April 22, 2010 at 5:04 pm, Anonymous said:

    good work, keep it up.

    Reply

  6. July 08, 2010 at 5:41 pm, Ace said:

    omg :0

    Ive totally forgot encapsulation dot1q 1 native in sub

    thanQ

    Reply

  7. September 28, 2010 at 8:58 am, Axiz said:

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

    Reply

  8. October 03, 2010 at 8:07 am, Hhaa111 said:

    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

    Reply

  9. July 29, 2011 at 9:52 pm, Markjunky said:

    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.

    Reply

  10. January 10, 2012 at 8:42 am, simone1 said:

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

    Reply

  11. March 28, 2012 at 11:35 pm, majid omidi said:

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

    Reply

  12. April 26, 2012 at 4:31 pm, Adam Stauffer said:

    Thanks, I was missing the native arguement on my router subif config and the trunk from the switch would not come up cause i was using something other than VLAN ID 1. :)

    Reply

  13. June 08, 2012 at 11:09 am, Vishal P. Bulbule said:

    Veryyyyyyyyyyy Gooooooooood. Thanks for help.

    Reply

  14. November 21, 2012 at 6:31 pm, Vic said:

    I tried this configuration using a Cisco 3750 switch that has 3750-ipbasek9-mz 122-25. SEE4.bin and a Cisco 2600 -D-M running 12.2(7). The trunk comes up but I am unable to ping the ip address for the respectives vlan on the 2600.

    Reply

Leave a Reply