1.主机设置
PC0:192.168.1.2 VLAN2 FA0/1 192.168.1.1
PC1:192.168.2.2 VLAN3 FA0/2 192.168.2.1
2.二层交换机设置
Switch>ena
---------创建VLAN2/3-------------------
Switch#vlan database
Switch(vlan)#vlan 2
Switch(vlan)#vlan 3
Switch(vlan)#exit
---------设置连接主机交换机端口为access并分别加入VLAN2/3-----------
Switch#conf t
Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
-------------设置与三层交换机相连接口为trunk并设置为全通过all---------------
Switch(config)#int fa0/3
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all
Switch(config-if)#
3.三层交换机设置
Switch>ena
---------为Fa0/1接口封装dot1q协议,并设置为trunk--------
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa0/1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#exit
Switch(config)#exit
---------创建VLAN2/3---------------
Switch#vlan database
Switch(vlan)#vlan 2
Switch(vlan)#vlan 3
Switch(vlan)#exit
-------为vlan 2设置ip192.168.1.1并开启------------
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 2
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
-------为vlan 3设置ip192.168.2.1并开启------------
Switch(config)#int vlan 3
Switch(config-if)#
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#
4.检查PC0(VLAN2 192.168.1.2) PING PC1(VLAN3 192.168.2.1)
https://www.lanzous.com/i3k29hg