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.

  • Haitham

    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

    • vtwin

      You need fastEthernet interface.

    • Dominusanubis

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

      c2600-d-mz

      • Dominusanubis

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

        • felix

          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

    • Bob

      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

  • felix

    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.

  • toni

    veryyyyyyyyyyyyyy good help

  • Tony

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

  • Anonymous

    good work, keep it up.

  • Ace

    omg :0

    Ive totally forgot encapsulation dot1q 1 native in sub

    thanQ

  • Axiz

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

  • Hhaa111

    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

  • Markjunky

    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.

  • simone1

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

  • majid omidi

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

  • Adam Stauffer

    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. :)

  • Vishal P. Bulbule

    Veryyyyyyyyyyy Gooooooooood. Thanks for help.

  • Vic

    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.