Layer-3 switches implement inter-VLAN Routing
Communication between different VLANs requires routing. There are two implementation methods. layer-3 switching enables routing or directly uses routers. This article describes how to use a layer-3 Switch to implement inter-vlan routing. I. Several concepts that are confusing during my learning process: 1. Local vlan and common vlan: A local vlan is also called a management vlan. Each switch has a default vlan 1, that is, the local vlan of the switch. By default, all ports of the switch are divided into vlan 1. A common vlan is a self-created vlan. Frames forwarded under a common vlan are tagged (such as dot1q) before they pass through the trunk port, and then transmitted between VLANs; frames under a local vlan are not tagged before they enter the trunk. when they enter the trunk port, a native vlan tag (nvtag) is created ), this tag is removed when the trunk is output. We can use commands to change the management vlan of a vswitch. 2. vswitch Virtual Interface SVI: we can create a virtual interface for the vlan of the switch. Command: # interfance vlan-id. We can configure an IP address for this virtual interface. We can use the ip address used to manage VLANs when logging on to a vswitch remotely. For a L2 Switch, we only configure the svi ip address for the management vlan of the switch. If you configure the IP address for a common vlan, it does not work. For a layer-3 switch, we configure its IP address for the management vlan for remote logon. For a common vlan, we configure its svi ip address as the gateway of the host under different VLANs. 3. layer-3 Switch routing: to use the routing function of a layer-3 switch, you must first enable the routing function of the layer-3 Switch. Command: # ip routing. You can use SVI to select a route for a layer-3 Switch. You can enable the layer-3 function of the layer-3 Switch physical interface and configure an IP address for the physical interface. The routing selection function of a layer-3 switch can use static routing or enable dynamic routing protocol. Ii. Next I will give a specific example. The network topology is as follows: There are two common VLANs in the topology, VLAN 10 and VLAN 20. PC7 and PC8 belong to VLAN10, and PC5 and PC6 belong to VLAN20. 1. layer-3 Switch configuration: 1) VLAN creation and Division: 3SW (config) # vlan 10 3SW (config-vlan) # exit 3SW (config) # vlan 20 3SW (config-vlan) # exit 2), create a SVI and assign an IP address to it (vlan1 configuration is optional) 3SW (config) # interface vlan 1 Manage vlan 3SW (config-if) # ip add 172.16.1.254 255.255.255.0 3SW (config) # interface vlan 10 3SW (config-if) # ip add 192.168.10.254 255.255.255.0 3SW (config-if) # no shutdown 3SW (config-if) # exit 3SW (config) # interface vlan 20 3SW (config-if) # ip Add 192.168.255.254 255.255.255.0 3SW (config-if) # no shutdown 3SW (config-if) # exit 3), start the routing function of layer-3 Switch 3SW (config) # ip routing2, SW1 configuration 1), VLAN creation and Division: SW1 (config) # vlan 10 SW1 (config-vlan) # exit SW1 (config) # vlan 20 SW1 (config-vlan) # exit SW1 (config) # interfance f0/1 SW1 (config-if) # switchport access vlan 10 SW1 (config-if) # exit SW1 (config) # interfance f0/2 SW1 (config-if) # switchport access vlan 20 SW1 (config-if )# Exit2), create a SVI for VLAN1 and assign it an ip address SW1 (config) # interface vlan 1 Management vlan SW1 (config-if) # ip add 172.16.1.3 255.255.255.0 SW1 (config-if) # exit3) change the port connecting SW1 to a layer-3 switch to the trunk mode SW1 (config) # interfance f0/3 SW1 (config-if) # switchport mode trunk SW1 (config-if) # exit3, SW2 configuration (similar to SW1 configuration) 1), VLAN creation and Division: SW2 (config) # vlan 10SW2 (config-vlan) # exitSW2 (config) # vlan 20SW2 (config-vlan) # exitSW2 (config) # interfance f0/3SW2 (config-if) # swi Tchport access vlan 10SW2 (config-if) # exitSW2 (config) # interfance f0/2SW2 (config-if) # switchport access vlan 20SW2 (config-if) # exit2) create SVI for VLAN1 and assign it the ip address SW2 (config) # interface vlan 1 to manage vlanSW2 (config-if) # ip add 172.16.1.4 255.255.255.0SW2 (config-if) # exit3) change the port connecting SW2 to a layer-3 switch to the trunk mode SW2 (config) # interfance f0/1SW2 (config-if) # switchport mode trunkSW2 (config-if) # exit4. Verify the connectivity of the test results. 1) assign an IP address to each host in the topology. Example: The configurations of the other three hosts are similar to those of PC7. The IP address of PC8 is 192.168.10.2, the gateway of PC8 is the same as that of PC7 (192.168.10.254), and the IP address of PC5 is 192.168.20.1, the IP address of PC6 is 192.168.20.2, PC5 and PC6 belong to VLAN20, And the gateway is 192.168.255.254. 2) ping PC8 (same VLAN) and PC5 (different VLAN) on PC7 respectively. The verification result is as follows: