Communication between different VLANs require router or some form of routing. Routing between the VLANs can be done using layer 3 switch or use more popular form of inter-vlan routing called router on a stick. Layer 3 switches are pretty expensive which is the main reason why router on a stick configuration is popular. In this post, I will show steps to Configure Inter VLAN Routing in Cisco Router also called router on a stick.
Configure Inter VLAN Routing in Cisco Router
The diagram below shows our scenario. The switch is configured with two VLANs 2 and 3. PCs in VLAN 2 will have IP of 192.168.2.0/24 network and PCs in VLAN 3 will have IP of 192.168.3.0/24 network. Similarly, Host A and Host E are on VLAN 3, and Host B and Host C are on VLAN 2. Each host have IP assigned as shown below.
I have already created VLANs in Switch1. For inter vlan routing to work, you need to create TRUNK link between Switch and the router. Here, we need to create TRUNK link between Switch1 and R1. Fa0/0 of R1 is connected to Fa0/7 of Switch1. The interface of router connected to switch must have sub interfaces created with dot1q encapsulation. A sub interface is a logical interface that is part of the physical interface. The sub interface can be configured with different IP address. You can configure many sub interfaces under same physical interface. Now, let’s start configuration with R1.
R1(config)#int fa0/0.2 %LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up R1(config-subif)#encapsulation dot1Q 2 R1(config-subif)#ip address 192.168.2.254 255.255.255.0 R1(config-subif)#exit R1(config)#int fa0/0.3 %LINK-5-CHANGED: Interface FastEthernet0/0.3, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.3, changed state to up R1(config-subif)#encapsulation dot1Q 3 R1(config-subif)#ip address 192.168.3.254 255.255.255.0
Above configuration creates two sub interfaces, fa0/0.2 and fa0/0.3. Command encapsulation dot1q 2 means this sub interface will accept frames tagged with VLAN 2 on them. IP address command simply assigns IP address to the sub interface. You can view the list of interface using, show ip interface brief command as shown below.
R1#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 unassigned YES unset up up FastEthernet0/0.2 192.168.2.254 YES manual up up FastEthernet0/0.3 192.168.3.254 YES manual up up FastEthernet0/1 unassigned YES unset administratively down down Vlan1 unassigned YES unset administratively down down
As you can see above interface fa0/0.2 and fa0/0.3 are up with their respective IP address configured. Now, let’s configure Switch1 with TRUNK interface.
Switch1(config)#int fa0/7 Switch1(config-if)#switchport trunk encapsulation dot1q Switch1(config-if)#switchport mode trunk %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/7, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/7, changed state to up
Now, let’s ping Host C (192.168.2.2) from Host E (192.168.3.2).
C:\Users\Bipin>ping 192.168.2.2 Pinging 192.168.2.2 with 32 bytes of data: Request timed out. Reply from 192.168.2.2: bytes=32 time=24ms TTL=127 Reply from 192.168.2.2: bytes=32 time=17ms TTL=127 Reply from 192.168.2.2: bytes=32 time=14ms TTL=127 Ping statistics for 192.168.2.2: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 14ms, Maximum = 24ms, Average = 18ms
In this way you can configure inter-vlan routing on Cisco switch and router.
You may also like -
Latest posts by Bipin (see all)
- Backup Exchange Mailboxes to PST with Iperius Backup - April 1, 2017
- Understanding Basics of EIGRP Routing Protocol - March 26, 2017
- Restore Accidentally Deleted Public Folder Database from EDB File - May 23, 2016