**PS:
1.sw是switchport缩写
2.m是mode缩写
3.acc是access缩写
4.all是allowed缩写
5.sh是shotdown缩写
6.tr是trunk缩写
7.ex是excluded-address缩写
8.add是address缩写
9.def是default-router缩写
10.ex是exit缩写
**
交换机1:
Switch(config)#(在全局模式下进行)
VLAN 10
VLAN 20
int f0/2
sw m acc
sw acc vlan 10
no sh
ex
int f0/3
sw m acc
sw acc vlan 20
no sh
ex
int f0/1
sw m tr
sw tr all vlan 10,20
no sh
交换机2:
Switch(config)#(在全局模式下进行)
VLAN 30
VLAN 40
int f 0/2
sw m acc
sw acc vlan 30
no sh
ex
int f0/3
sw m acc
sw acc vlan 40
no sh
ex
int f0/1
sw m tr
sw tr all vlan 30,40
no sh
交换机0:
Switch(config)#(在全局模式下进行)
VLAN 10
VLAN 20
VLAN 30
VLAN 40
int f0/1
sw m tr
sw tr all vlan 10,20,30,40
no sh
ex
int f0/2
sw m tr
sw tr all vlan 10,20
no sh
ex
int f0/3
sw m tr
sw tr all vlan 30,40
no sh
MS0:(最上面的交换机)
Switch(config)#(在全局模式下进行)
vlan 10
vlan 20
vlan 30
vlan 40
int f0/1
sw tr all vlan 10,20,30,40
ex
ip dhcp ex 192.168.10.1
ip dhcp ex 192.168.20.1
ip dhcp ex 192.168.30.1
ip dhcp ex 192.168.40.1
int vlan 10
ip add 192.168.10.1 255.255.255.0
ip routing
ip dhcp pool 10
network 192.168.10.0 255.255.255.0
def 192.168.10.1
ex
int vlan 20
ip add 192.168.20.1 255.255.255.0
ip routing
ip dhcp pool 20
network 192.168.20.1 255.255.255.0
def 192.168.20.1
ex
int vlan 30
ip add 192.168.30.1 255.255.255.0
ip routing
ip dhcp pool 30
network 192.168.30.0 255.255.255.0
def 192.168.30.1
ex
int vlan 40
ip add 192.168.40.1 255.255.255.0
ip routing
ip dhcp pool 40
network 192.168.40.0 255.255.255.0
def 192.168.40.1
最后回到pc上
单击pc0 选择Desktop
点击第一个图案(带有106的)
将Static换为DHCP
自动分配地址
上图是已更换的
剩余pc配置方法一致
最后使用pc相互ping看是否通信正常