Sunday, March 24, 2019

InterVLAN Routing - Layer3 Switch

I try to do inter VLAN Routing without using Router.  Usually if layer 2 switches are used, we have to use a router to do inter VLAN Routing.  I use a standalone layer 3 switch to create VLAN and route packets between them.

Topology
There are 3 PCs in 3 different networks, and a layer3 switch.

Task Breakdown
  1. Configure IP Addresses in PCs
  2. Create VLANs in switch
  3. Configure Layer3 parameters in switch
  4. Validate configuration
1. Configure IP Addresses in PCs

PC Name IP Address Subnet Mask Default Gateway
PC-NET-1 172.1.0.100 255.255.0.0 172.1.0.1
PC-NET-2 172.2.0.100 255.255.0.0 172.2.0.1
PC-NET-3 172.3.0.100 255.255.0.0 172.3.0.1

Click on PC-> Desktop -> IP Configuration

Static IP Configuration in PC

2. Create VLANs in switch

Creating 3 VLANs 101, 102, 103 for PC-NET-1, PC-NET-2, PC-NET-3 respectively.

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 101
Switch(config-vlan)#exit
Switch(config)#vlan 102
Switch(config-vlan)#exit
Switch(config)#vlan 103
Switch(config-vlan)#exit
Switch(config)#

Assign the switch ports fa0/1(connected to PC-NET-1), fa0/2(connected to PC-NET-2) and fa0/3(connected to PC-NET-3) to VLAN 101, 102 and 103 respectively.

PC Name IP Address Subnet Mask Default Gateway Switchport interface VLAN ID
PC-NET-1 172.1.0.100 255.255.0.0 172.1.0.1 fa0/1 VLAN 101
PC-NET-2 172.2.0.100 255.255.0.0 172.2.0.1 fa0/2 VLAN 102
PC-NET-3 172.3.0.100 255.255.0.0 172.3.0.1 fa0/3 VLAN 103

Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 101
Switch(config-if)#exit
Switch(config)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 102
Switch(config-if)#exit
Switch(config)#int fa0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 103
Switch(config-if)#exit

3. Configure Layer3 parameters in switch

Configure IP addresses to VLANs like the following.  IP addresses has to match the default gateway configured in the respective PCs

Switch(config)#int vlan 101
Switch(config-if)#ip address 172.1.0.1 255.255.0.0
Switch(config-if)#exit
Switch(config)#int vlan 102
Switch(config-if)#ip address 172.2.0.1 255.255.0.0
Switch(config-if)#exit
Switch(config)#int vlan 103
Switch(config-if)#ip address 172.3.0.1 255.255.0.0
Switch(config-if)#exit
Switch(config)#

To enable layer3 switch's capability to route packets, the following command has to be given

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#exit
Switch#

To view the routing table of the switch

Switch#show ip route 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

C    172.1.0.0/16 is directly connected, Vlan101
C    172.2.0.0/16 is directly connected, Vlan102
C    172.3.0.0/16 is directly connected, Vlan103

4. Validation 

Ping test has to be done from any PC to the other two PCs

Click on PC-NET-2 -> Desktop -> Command Prompt
Successful Ping from PC-NET-2

No comments:

Post a Comment