TechKnowSurge
Cisco CCNA 2.1 Cisco CCNA 2.2 Cisco CCNA 3.3
VideoNetworkFree

DEMO: Configuring Router-on-a-Stick

Router on a stick is a network design that enables inter-VLAN routing through a single physical link between a router and a switch, using 802.1Q-tagged subinterfaces to handle traffic for multiple VLANs. This content covers the concept and a full configuration walkthrough on Cisco hardware, including real-world troubleshooting.

Complete this video to capture a CTF flag worth 1 point.

About this video

Router on a stick is an inter-VLAN routing technique that uses a single physical link between a router and a switch to carry traffic for multiple VLANs. Rather than requiring a dedicated router interface for each VLAN, the physical interface is subdivided into logical subinterfaces, each assigned a VLAN ID and a corresponding gateway IP address. The switch port on the other end of the link is configured as an 802.1Q trunk, tagging outgoing frames with VLAN information so the router can identify which subinterface should process each packet. This approach is efficient and commonly used in smaller network environments where additional physical interfaces are not practical or available. On the Cisco router, configuration begins by removing any existing IP address from the physical interface, then entering each subinterface individually. Each subinterface is configured with the encapsulation dot1q command followed by the matching VLAN ID, and then assigned an IP address that will serve as the default gateway for hosts on that VLAN. For the native VLAN, the native keyword is appended to the encapsulation statement to handle untagged traffic correctly. Matching the subinterface number to the VLAN ID is a widely followed convention that simplifies management and reduces configuration errors. The demonstration also covers a realistic troubleshooting scenario encountered during the lab. After completing the initial configuration, inter-VLAN connectivity failed to establish. Diagnostic commands including show ip interface brief, show run, show ip route, and show interfaces switchport revealed that the switch port connecting to the router was operating in access mode rather than trunk mode. The root cause was a missing trunk encapsulation command specific to the Cisco 3750 platform, which requires switchport trunk encapsulation dot1q before switchport mode trunk can be applied. Unlike the 2960 series, the 3750 does not default to 802.1Q encapsulation, and Dynamic Trunking Protocol did not negotiate the trunk automatically with the router as it had with other switches in the topology. Once the correct commands were entered on the switch interface, the trunk came up and routing between VLAN 10 and VLAN 20 succeeded.

What you'll learn

What's covered

Router on a Stick

Aligned to

Cisco CCNA
2.1 Configure and verify VLANs (normal range) spanning multiple switches
2.2 Configure and verify interswitch connectivity
3.3 Configure and verify IPv4 and IPv6 static routing

Key terms

Virtual LAN
VLAN
A logical grouping of network devices that behave as if they are on the same network regardless of physical location.
Router
A network device that forwards data packets between networks based on IP addresses.
Switch
A network device that connects devices within a LAN and forwards traffic based on MAC addresses.
Encapsulation
The process of wrapping data with protocol headers as it passes down the layers of the OSI model.
Router-on-a-Stick
An inter-VLAN routing design in which a single physical router interface is connected to a switch trunk and divided into subinterfaces, one per VLAN, each configured with 802.1Q encapsulation and the default gateway address for that VLAN's subnet.
Subinterface
A logical subdivision of a physical router interface that allows it to carry traffic for multiple VLANs, each assigned a unique VLAN ID and IP address.
802.1Q
The IEEE standard that defines VLAN tagging, specifying how a 4-byte tag is inserted into an Ethernet frame to identify its VLAN membership across trunk links.
Trunk Port
A switch port that carries traffic for multiple VLANs over a single link by tagging frames with their VLAN ID, used between switches or between a switch and a router. All VLANs are tagged except the native VLAN.
Native VLAN
The one VLAN on an 802.1Q trunk whose frames are sent untagged. Any untagged frame received on the trunk is assigned to it. Both ends of a trunk must be configured with the same native VLAN.

Topics

Networking Inter Vlan Routing Router On A Stick 802 1q Vlans Cisco Ios Trunk Ports

Transcript

What Router on a Stick Is

Router on a stick is the idea that we have a router, and then we have a single Ethernet cable going into that router, plugged into the switch, for all the VLANs that are connected to it. We do this by using sub-interfaces.

What I've already done is I've set up an Ethernet cable between our router and our switch. On the switch I've plugged it into fa1/0/47, so that is the port that I'm plugged into there. On this router I plugged it into fa0/1. Those are the interfaces that we are going to be configuring on each of those devices.

Then we're going to set up this line to be 802.1Q, which means it adds the tag for the VLAN information. So this switch right here, when it sends a packet across this line, it's going to add the tag with the VLAN information, so then this router knows how to handle it. Then we'll set up IP addresses on this router using what we call sub-interfaces. We have the interface fa0/1, and then we're going to have sub-interfaces to it and we'll give them IDs. So VLAN 10 will probably have a sub-interface of 10, and then we'll give it an IP address — that'll be 10.1.10.1 will be the address for it. That's how we're going to set this up and configure it.

The Starting Point

I have my notes here on the top right, and I have my network diagram. I've got a connection to S1, S2 and S3, even though we're just going to be configuring S1 and the router in this demo. I'm also pinging 10.1.10.21, which is my demo Pi 1 — it's on the same network, same VLAN, so I've got connectivity there. Then I'm pinging 10.1.20.22, and you can see it's timing out because I don't have any routing between these networks at this point in time.

Checking the Trunk on the Switch

In our last module we set up trunk lines on our switches, so let's take a look at how we configured that. I'm going to do a show run interface fa1/0/47 — this is the interface that I said I've got connected into the router — and I'm going to hit enter on that. I've got the correct description in there. The trunk native is VLAN 2; that's important, we will see that when we go to configure the router. Then the VLANs that are allowed are 2, 10, 20, 30, 40, 50 and 150. Those are going to be the VLANs we would want to configure on the switch. For the purpose of this demo we're just going to do VLAN 10 and 20, but we could go through and configure all of the VLANs this way, so that all of the VLANs are routed through this same trunk line right here.

Configuring the Router

Since switch 1 is already configured the way we want it, now it's time to go to the router and configure the router the way we want it. I've consoled into the router, because at this point in time I don't have connectivity into it, so I'm going to have to jump in here and enter my passwords in from my password manager.

Now I'm into this router, and I'm going to do a show run interface fa0/1 — that is the interface that we want to configure. So it's the IP address of something we've done quite a while ago, in one of our past modules, so we're going to need to change this.

Let's get into the global configuration mode and get into interface fa0/1. The description, "headquarters network linked to HQ S1", is still valid, so that's still good. Then we have an IP address, and we're going to take that IP address out of here, so let's remove that right there. We're also going to remove this one right here — we don't want these messing up our configuration — so we'll take both of those out of there.

Creating the Sub-Interfaces

Now what I'm going to do is get into what we had talked about, the sub-interface. The first sub-interface I'm going to do is VLAN 10, so I'll do up arrow to quickly get in here, and I'm going to create a sub-interface. I'm configuring it for VLAN 10. I could do the sub-interface .1 — it's just the first sub-interface — or I could do a sub-interface of 23. I can specify whatever sub-interface that I want; it's just a designator to keep it separate from every other sub-interface on this interface. So it really doesn't matter what the ID is, what number I'm going to give this sub-interface, but for consistency purposes I always like it to match up with my VLAN. So in this case right here I'm going to actually do sub-interface 10, so fa0/1.10 is going to be the sub-interface. I'm going to hit enter on that, and now I'm into the sub-interface. You can see that it actually shows me that I'm in the sub-interface right here, and I'm in the sub-interface of fa0/1.10.

Next I'm going to configure it to be able to accept the 802.1Q tagging. The first thing that I'll do is put a description into this, so I'm going to do a description and we'll just put "VLAN sub interface", and we'll hit enter. Then next, dot1Q — that is the protocol, the definition of the protocol of that tagging and what the tagging looks like. So I'm going to do dot1Q and then the VLAN ID, and this is VLAN ID of 10. That number right there is important: it does need to line up with the VLAN tagging, so that is very specific, we need VLAN 10 there. We hit enter, and now it can interpret that coming across there. Then we'll give this an IP address, 10.1.10.1.

Of course we will also want to set up VLAN 20 for this communication to happen. So I can get into the next sub-interface, and once again I always like the ID to match the VLAN, so .20 is what I'm going to choose. I'm going to put in a description here, but instead of 10 we're going to have a description of 20, so I'll put in 20 here and hit enter. I want this dot1Q statement right here, but instead of 10 we're going to say VLAN 20, so there's that. Then we're going to get an IP address in here as well, and we will want to change the IP address to match that of something in VLAN 20. So now I have an IP address associated with VLAN 20 and it is tagged with 20, and I have the same thing for 10 and this is tagged with VLAN 10.

The Native VLAN

The one other thing that I will mention is that we do have that VLAN 2, which is the native VLAN, so I'll show you how to get into that interface. We're going to create another sub-interface, but this sub-interface is just going to be 2, so it's going to be 0/1.2 so it matches up with that VLAN ID. We want the encapsulation — well, let's do a description here first, so description, and we'll hit enter. Then the dot1Q: we will specify that, but what we'll do is we'll include that it's going to be VLAN 2, and we'll include this word "native" in here. So native right there, and remember that's going to be the untagged traffic. I'm going to hit native and hit enter, and now VLAN 2 is the untagged traffic because I just specified it right there.

I'm going to exit out of here, and just in case, I'm going to do a no shutdown on the interface. I do need to be in the interface of fa0/1, so let's do zero one, and no shut on it.

Troubleshooting the Trunk

I waited quite a while and it never came up, so I had to do some troubleshooting, which is just part of the process. Quite often you'll find that things don't go quite as planned and you'll have to do some troubleshooting. So I used the show ip interface brief to take a look at my interfaces and make sure that they were up. I did the show run to take a look at those interfaces. I took a look at the IP route, which we haven't gone over really in this course yet, to take a look and see if the routing table looked correct. All in all, most everything looked fine, but something did catch my eye.

I went to switch 1 and looked at our interface, and here where it said operational mode — most of this was fine, but where it said operational mode, it said that it was an access port, and so that is what flagged that something is off. So I did this command, show interface fa1/0/47 switchport, took a look at it, and once again I saw operational mode said access. Then I took a look at the running config — I'll do a show run interface fa1/0/47 — and when I took a look at this interface, I didn't have this switchport mode trunk in there. So I entered the switchport mode trunk in, which gave me an error. I did some Googling and figured out that on the 3750 I actually needed to type in switchport trunk encapsulation dot1q. So because of the type of switch I had, I had a couple of extra commands that I had to enter in.

This command should have been on there — I went over this in one of the prior videos — it's just that it didn't take on the 3750. It was still able to communicate out to the other switches, because DTP kicked in and everything worked out okay with communicating to the other switches. But because this router probably doesn't have DTP set up on it and turned on and configured, or maybe it's not even possible on that, it didn't automatically create this trunk line between those two devices, and so I had to go and enter in a couple of manual commands in here. That was not standard for this; if I had one of my 2960s we wouldn't have necessarily had this issue.

So just keep that in mind: you have to do a little bit of troubleshooting to figure out some of these commands, and every switch is a little different in some of the ways that you can configure them. But you can see down here I'm pinging both demo Pi 1 and demo Pi 2, so we are good to go.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →