Configure ROAS

To allow interVLAN communication, you can divide a single physical interface on a router into logical interfaces that will be configured as trunk interfaces. This method of interVLAN communication is called router on a stick (ROAS) and enables all VLANs to communicate through a single physical interface. The physical interface is divided into logical interfaces (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:

  1. (config)# interface TYPE NUMBER.SUBINTERFACE – creates the subinterface and enters the subinterface command mode.
  2. (config-subif)# encapsulation dot1q VLAN_ID – sets the subinterface to trunk and associates it with a specific VLAN.
  3. (config-subif)# ip address IP_ADDRESS SUBNET_MASK – sets the IP address for the subinterface.

 

We will use the following network in our example:

Router on a stick example network

We have a 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 Gi0/0 into logical interfaces, one for each VLAN. But first, here is the configuration of the switch:

SW1(config)#int fa0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 3
% Access VLAN does not exist. Creating vlan 3
SW1(config-if)#int fa0/4
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
SW1(config-if)#int fa0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 5
% Access VLAN does not exist. Creating vlan 5
SW1(config-if)#int fa0/1
SW1(config-if)#switchport mode trunk

Notice how we’ve configured the Fa0/1 port on a switch (the port connected to the router’s Gi0/0 interface) as the trunk port. Other ports were configured as access ports and placed into respective VLANs since they are connected to end devices. Now, let’s configure the router:

R1(config)#int Gi0/0
R1(config-if)#no shutdown

R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

R1(config-if)#int Gi0/0.1
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.1, changed state to up

R1(config-subif)#encapsulation dot1q 3
R1(config-subif)#ip address 10.0.3.1 255.255.255.0
R1(config-subif)#int Gi0/0.2
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.2, changed state to up

R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 10.0.10.1 255.255.255.0
R1(config-subif)#int Gi0/0.3
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.3, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.3, changed state to up

R1(config-subif)#encapsulation dot1q 5
R1(config-subif)#ip address 10.0.5.1 255.255.255.0

In the output above you can see that the router’s physical interface Gi0/0 was divided into three subinterfaces that were then configured as trunk interfaces and assigned the IP addresses.

To test whether the intervlan communication works, we can try to ping Host C from Host A:

C:\>ping 10.0.5.10

Pinging 10.0.5.10 with 32 bytes of data:

Reply from 10.0.5.10: bytes=32 time<1ms TTL=127
Reply from 10.0.5.10: bytes=32 time=1ms TTL=127
Reply from 10.0.5.10: bytes=32 time<1ms TTL=127
Reply from 10.0.5.10: bytes=32 time<1ms TTL=127

As you can see from the output above, the response was received, which means that the hosts can communicate even though they are in different VLANs.

upravnik