To allow communication between LANs, you can divide a single physical interface into a router into logical interfaces that will be configured as trunk interfaces. This method of interVLAN communication is called a router in a stick (ROAS) and allows all VLANs to communicate through a single physical interface. The physical interface is divided into logical interfaces (known as subinterfaces), one for each VLAN.
Response of 10.0.5.10: bytes = 32 times <1 ....="" .1="" 0.1="" 0.="" 10.0.5.10:="" a="" and="" are="" as="" be.="" br="" bytes="32" can="" command="" communicate="" created="" creates="" different="" even="" example="" for="" generally="" gi0="" hosts="" in="" interface.="" interface="" is="" means="" ms="" number.subinterface="" number="" of="" on="" output="" period="" physical="" port="" previous="" received="" response="" same="" see="" starts="" subinterface="" that="" the="" they="" though="" time="1" times="" ttl="127" type="" under="" vlan="" vlans="" was="" which="" will="" with="" you="">
To configure the link in a router, the following commands are used:
1>
(config) # interface TYPE NUMBER.SUBINTERFACE - creates the subinterface and enters the command mode of the subinterface.
(config-subif) # encapsulation dot1q VLAN_ID: sets the subinterface on the trunk and associates it with a specific VLAN.
(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 in 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 interface of the Gi0 / 0 router into logical interfaces, one for each VLAN. But first, here is the switch configuration:
SW1 (config) #int fa0 / 3
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 3
% Access to the VLAN does not exist. Creating vlan 3
SW1 (config-if) #int fa0 / 4
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 10
% Access to the VLAN does not exist. Creating vlan 10
SW1 (config-if) #int fa0 / 2
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 5
% Access to the VLAN does not exist. Creating vlan 5
SW1 (config-if) #int fa0 / 1
SW1 (config-if) #switchport trunk mode
Notice how we configure 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 in the respective VLANs since they are connected to the end devices. Now, let's configure the router:
R1 (config) #int Gi0 / 0
R1 (config-if) #no shutdown
R1 (config-if) #
% LINK-5-CHANGED: GigabitEthernet0 / 0 interface, status change to top
% LINEPROTO-5-UPDOWN: Line protocol in GigabitEthernet0 / 0 interface, change status to up
R1 (config-if) #int Gi0 / 0.1
R1 (config-subif) #
% LINK-5-CHANGED: GigabitEthernet0 / 0.1 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.1 interface, change status 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: GigabitEthernet0 / 0.2 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.2 interface, change status 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: GigabitEthernet0 / 0.3 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.3 interface, change status to up
R1 (config-subif) # encapsulation dot1q 5
R1 (config-subif) #ip address 10.0.5.1 255.255.255.0
In the previous output, you can see that the physical interface Gi0 / 0 of the router was divided into three subinterfaces that were then configured as trunk interfaces and the IP addresses were assigned.
To test if 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:
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 time = 1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
As you can see in the previous output, the response was received, which means that the hosts can communicate even though they are in different VLANs ....
To configure the link in a router, the following commands are used:
1>
(config) # interface TYPE NUMBER.SUBINTERFACE - creates the subinterface and enters the command mode of the subinterface.
(config-subif) # encapsulation dot1q VLAN_ID: sets the subinterface on the trunk and associates it with a specific VLAN.
(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 in 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 interface of the Gi0 / 0 router into logical interfaces, one for each VLAN. But first, here is the switch configuration:
SW1 (config) #int fa0 / 3
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 3
% Access to the VLAN does not exist. Creating vlan 3
SW1 (config-if) #int fa0 / 4
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 10
% Access to the VLAN does not exist. Creating vlan 10
SW1 (config-if) #int fa0 / 2
Access SW1 (config-if) #switchport mode
SW1 (config-if) #switchport access vlan 5
% Access to the VLAN does not exist. Creating vlan 5
SW1 (config-if) #int fa0 / 1
SW1 (config-if) #switchport trunk mode
Notice how we configure 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 in the respective VLANs since they are connected to the end devices. Now, let's configure the router:
R1 (config) #int Gi0 / 0
R1 (config-if) #no shutdown
R1 (config-if) #
% LINK-5-CHANGED: GigabitEthernet0 / 0 interface, status change to top
% LINEPROTO-5-UPDOWN: Line protocol in GigabitEthernet0 / 0 interface, change status to up
R1 (config-if) #int Gi0 / 0.1
R1 (config-subif) #
% LINK-5-CHANGED: GigabitEthernet0 / 0.1 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.1 interface, change status 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: GigabitEthernet0 / 0.2 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.2 interface, change status 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: GigabitEthernet0 / 0.3 interface, status change to top
% LINEPROTO-5-UPDOWN: line protocol in GigabitEthernet0 / 0.3 interface, change status to up
R1 (config-subif) # encapsulation dot1q 5
R1 (config-subif) #ip address 10.0.5.1 255.255.255.0
In the previous output, you can see that the physical interface Gi0 / 0 of the router was divided into three subinterfaces that were then configured as trunk interfaces and the IP addresses were assigned.
To test if 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:
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 time = 1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
Response of 10.0.5.10: bytes = 32 times <1 ms TTL = 127
As you can see in the previous output, the response was received, which means that the hosts can communicate even though they are in different VLANs ....