The routing between VLANs can be achieved by using a Layer 2 switch with a router or by using a Layer 3 switch
One-arm routing : Configure the link between the switch and the router as a trunk link, and create sub-interfaces on the router to support VLAN routing
The configuration steps of single-arm routing are as follows:
(1) Configuration commands on the switch:
vlan batch 2 3 在交换机上创建两个vlan
The switch and router interconnect ports are set to trunk and allow vlan to pass
port link-type trunk
port trunk allow-pass vlan all
(2) Configuration commands on the router:
Set up a sub-interface on the interface connecting the router and the switch to act as a gateway for different VLANs
interface GigabitEthernet0/0/1.1 进入子接口
ip address XXXX 设置网关地址
dot1q termination vid X 让子接口能接收相应的vlan标记并在转发时能打上相应的tag
arp broadcast enable 开启arp广播
In order to solve the problems caused by single-arm routing, a three-layer switch is introduced to realize the mutual access between VLANs more conveniently and effectively. The three-layer switch has the routing function by creating vlanif to act as the next hop address of a network segment, so as to achieve the routing function to a network segment. The interconnection interface of the three-layer switch must be set to trunk mode, so as to realize the communication between the two three-layer switches. The prerequisite for creating vlanif is to create the relative vlan first. If vlanif works, it will be up only if it is applied to the interface.
Make the following configuration on one of the three-layer switches
vlan 20 创建vlan20
interface vlanif 20 创建vlanif和vlan编号要相对应
ip address X.X.X.X 在vlanif接口下配置ip地址
interface g0/0/0 进入接口
port link-type access 设置接口类型
port default vlan 20 将vlan分配到具体接口上,vlanif才会起作用
Similarly, in the other three switches corresponding configuration also added; followed by link-type trunk
the link setting between two three switches are connected as trunk and by port trunk allow-pass vlan all
setting allows all trunk roads by vlan
Then add vlanifs to the respective networks on the two three-layer switches to achieve mutual access between the two network segments. At this time, the two three-layer switches are regarded as routers. The routing table of each router must There is a route to the destination network to achieve mutual visits
Use the display ip routing-table
command to check whether there is a route to the corresponding network segment, and add the corresponding vlanif if not
display ip interface brief
View the vlanif interface status through commands