1.拓扑图
PC1 :192.168.1.2
PC2:192.168.2.2
PC3:192.168.2.3
PC4:192.168.1.3
S1的f0/1连接CoreSW的f0/1,f0/2连接PC1,f0/3连接PC2
S2的f0/1连接CoreSW的f0/2,f0/2连接PC3,f0/3连接PC4
2.设置VTP
CoreSW:
CoreSW#vlan database 进入vlan设置模式
CoreSW(vlan)#vtp domain hello 设置vtp域名
CoreSW(vlan)#vtp server 将CoreSW设置为server
CoreSW(vlan)#vtp password 123 设置vtp密码
CoreSW(vlan)#exit
CoreSW#conf t
CoreSW(config)#int f0/1
CoreSW(config-if)#switchport trunk encapsulation dot1q 是用dotlq协议封装vlan
CoreSW(config-if)#switchport mode trunk 设置连接为trunk,默认为auto,线路两端要有一端为主动设置trunk,这里设置后二层交换机上就不用设置
CoreSW(config)#int f0/2
CoreSW(config-if)#switchport trunk encapsulation dot1q
CoreSW(config-if)#switchport mode trunk
S1:
S1#vlan database
S1(vlan)#vtp domain hello
S1(vlan)#vtp client 将S1设置成client
S1(vlan)#vtp password 123
S1(vlan)#exit
S2:
S2#vlan database
S2(vlan)#vtp domain hello
S2(vlan)#vtp client 将S1设置成client
S2(vlan)#vtp password 123
S2(vlan)#exit
3.划分Vlan
CoreSW:
CoreSW(config)#vlan 10
CoreSW(config-vlan)#name one
CoreSW(config-vlan)#exit
CoreSW(config)#vlan 20
CoreSW(config-vlan)#name two
CoreSW(config-vlan)#exit
CoreSW(config)# int vlan 10
CoreSW(config-if)#ip add 192.168.1.1 255.255.255.0 设置vlan10网关
CoreSW(config-if)#no sh
CoreSW(config-if)#exit
CoreSW(config)#int vlan 20
CoreSW(config-if)#ip add 192.168.2.1 255.255.255.0 设置vlan20网关
CoreSW(config-if)#no sh
CoreSW(config-if)#exit
S1:
S1(config)#int f0/2
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10 将端口添加进vlan10
S1(config)#int f0/3
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20 将端口添加进vlan20
S2:
S2(config)#int f0/2
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 20 将端口添加进vlan20
S2(config)#int f0/3
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 10 将端口添加进vlan10
4.开启三层交换机路由功能
CoreSW:
CoreSW(config)#ip routing 开启三层交换机的路由功能,如不开启跟二层交换机一样