HSRP等服务的综合图
实验环境:小凡模拟器
实验准备:一个路由器,6个交换机,虚拟PC
实验目的:PC2,PC2,PC4,PC5各能ping通PC1,PC1模拟外网,PC2,PC3,PC4不能和PC5通信,且如果一台三层交换有问题,不影响上网。
注:图上的三层交换用sw1,sw2代替,二层交换从左到右为sw3,sw4,sw5,sw6
实验步骤:
先做个实验外的准备:
Router(config)#no ip do lo 禁用解析,目的在输入错误的时候不解析
Router(config)#lin console 0
Router(config-line)#logging synchronous 开启同步
Router(config-line)#exec-timeout 0 永不超时 目的不初始化
以上可以不做
1.配置trunk口,本实验有20个trunk口:
sw1(config)#int range f0/1 -4 , f0/11 - 12
sw1(config-if-range)#switchport mode trunk
sw2配置如sw1,此处省略
sw3(config)#int range f0/1 - 2
sw3(config-if-range)#switchport mode trunk
sw4,sw5,sw6的配置与sw3相同。此处略
2.配置vtp,划分VLAN: vtp为自动下发vlan
配置客户端:
sw2#vlan database
sw2(vlan)#vtp client
sw2(vlan)#vtp password 123 vtp的密码
sw2(vlan)#exit
APPLY completed.
sw2,sw3,sw4,sw5,sw6的配置相同,此处略
sw1#vlan database
sw1(vlan)#vtp domain benet.com
sw1(vlan)#vtp password 123
sw1(vlan)#vlan 3
sw1(vlan)#vlan 4
sw1(vlan)#vlan 5
sw1(vlan)#exit
APPLY completed.
查看各交换是否学到了vlan:
sw2#show vlan-switch brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/13
Fa0/14, Fa0/15
2 VLAN0002 active
3 VLAN0003 active
4 VLAN0004 active
5 VLAN0005 active
经验证已经所有交换机都学到了vlan
3.配置二层交换把vlan加入接口:
sw3:sw3(config)#int f0/11
sw3(config-if)#switchport access vlan 2
sw4:
sw4(config)#int f0/11
sw4(config-if)#switchport access vlan 3
sw5:sw5(config-if)#switchport access vlan 4
sw6:sw6(config-if)#switchport access vlan 5
4.配置三层交换生成树:sw1为vlan2,vlan3的根,vlan4.vlan5的备份根,sw2为vlan4,vlan5的根,vlan2,vlan3的备份根:
sw1: sw1(config)#spanning-tree vlan 2 root primary
sw1(config)#spanning-tree vlan 3 root primary
sw1(config)#spanning-tree vlan 4 root secondary
sw1(config)#spanning-tree vlan 5 root secondary
sw2:sw2(config)#spanning-tree vlan 2 root secondary
sw2(config)#spanning-tree vlan 3 root secondary
sw2(config)#spanning-tree vlan 4 root primary
sw2(config)#spanning-tree vlan 5 root primary
5.配置速端口4个,配置以太网通道:
sw3:sw3(config)#int f0/11
sw3(config-if)#spanning-tree portfast
sw4,sw5,sw6配置与sw3相同,此处略
sw1:sw1(config)#int range f0/11 - 12
sw1(config-if-range)#channel-group 1 mode on
sw2与sw1的速端口配置相同,此处略
6.启用三层交换的路由功能,并配置ip:
sw1:sw1(config)#ip routing
sw1(config)#int vlan 2
sw1(config-if)#ip add 192.168.2.251 255.255.255.0
sw1(config-if)#int vlan 3
sw1(config-if)#ip add 192.168.3.251 255.255.255.0
sw1(config-if)#int vlan 4
sw1(config-if)#ip add 192.168.4.251 255.255.255.0
sw1(config-if)#int vlan 5
sw1(config-if)#ip add 192.168.5.251 255.255.255.0
sw2:sw2(config)#ip routing
sw2(config)#int vlan 2
sw2(config-if)#ip add 192.168.2.252 255.255.255.0
sw2(config-if)#int vlan 3
sw2(config-if)#ip add 192.168.3.252 255.255.255.0
sw2(config-if)#int vlan 4
sw2(config-if)#ip add 192.168.4.252 255.255.255.0
sw2(config-if)#int vlan 5
sw2(config-if)#ip add 192.168.5.252 255.255.255.0
7.在三层交换上搭建dhcp服务,以便PC能自动获得ip:
sw1:sw1(config)#ip dhcp pool 2
sw1(dhcp-config)#network 192.168.2.0
sw1(dhcp-config)#dns-server 202.106.0.20
sw1(dhcp-config)#default-router 192.168.2.254
sw1(config)#ip dhcp pool 3
sw1(dhcp-config)#network 192.168.3.0
sw1(dhcp-config)#dns-server 202.106.0.20
sw1(dhcp-config)#default-router 192.168.3.254
sw1(config)# ip dhcp pool
sw1(dhcp-config)#network 192.168.4.0
sw1(dhcp-config)#dns-server 202.106.0.20
sw1(dhcp-config)#default-router 192.168.4.25
sw1(config)#ip dhcp pool 5
sw1(dhcp-config)#network 192.168.5.0
sw1(dhcp-config)#dns-server 202.106.0.20
sw1(dhcp-config)#default-router 192.168.5.254