Configure router on a stick
To enable inter-VLAN communication, you can divide a single physical interface on a router into logical interfaces that will be configured as trunk interfaces. This scenario is called router on a stick (ROAS) and allows all VLANs to communicate through a single physical interface. The physical interface is divided into logical interfaces (also known as subinterfaces), one for each VLAN.
A subinterface is created with the interface TYPE NUMBER.SUBINTERFACE command. The subinterface number begins with the period and it is usually the same as the VLAN the subinterface will be in. For example, the command interface Gi0/0.1 creates a subinterface .1 under the physical Gi0/0 port.
To configure trunking on a router, the following commands are used:
- (config)# interface TYPE NUMBER.SUBINTERFACE – creates the subinterface and enters the subinterface command mode.
- (config-subif)# encapsulation dot1q VLAN_ID – sets the subinterface to trunk and associates it with a specific VLAN.
- (config-subif)# ip address IP_ADDRESS SUBNET_MASK – sets the IP address for the subinterface.
Consider the following example network:
We have a simple network of three hosts, a switch and a router. Each host is in a different VLAN, so we need to divide the physical router’s interface Fa0/0 into logical interfaces, one for each VLAN. But first, here is the switch configuration:
Notice how we’ve configured the Fa0/1 port on a switch (the port connected to the router’s Fa0/0 interface) as a trunk port. Now, let’s configure the router:
In the picture above you can see that the router’s physical interface Fa0/0 was divided into three subinterfaces that were then configured as trunk interfaces and given the IP addresses.