实验要求
如下面实验拓扑图
要求如下:
1 内网IP地址172.16.0.0/16 合理分配
2 SW1 和SW2间互为备份
3 VRRP STP VLAN TRUNK均使用
4 所有PC通过DHCP来获取ip
配置
在交换配置部分一般先进行交换机的配置,最后再配置路由ip。而路由部分,先配ip再配置交换机。
一般交换的配置涉及VLAN trunk svi channel STP vrrp dhcp 等配置
该题目的配置顺序可以为:也是一般交换配置的顺序
channel,VLAN ,trunk, stp, svi, vrrp, DHCP
ip地址划分
三层交换机间的channel
[SW1]int Eth-Trunk 0
[SW1-GigabitEthernet0/0/22]int g0/0/22
[SW1-GigabitEthernet0/0/22]eth-trunk 0
[SW1-GigabitEthernet0/0/22]int g0/0/23
[SW1-GigabitEthernet0/0/23]eth-trunk 0
可以看到 g0/0/22 g0/0/23口不见了 合成了Eth-Trunk 0
[SW2]interface Eth-Trunk 0
[SW2-Eth-Trunk0]int g0/0/22
[SW2-GigabitEthernet0/0/22]eth-trunk 0
[SW2-Eth-Trunk0]int g0/0/23
[SW2-GigabitEthernet0/0/23]eth-trunk 0
创建VLAN
[SW1]vlan 2
[SW1-vlan2]q
[SW1]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 Eth
-Trunk 0 一次多次将VLAN划分
[SW1-port-group]port link-type trunk
[SW1-port-group]port trunk allow-pass vlan 2
[SW2]vlan 2
[SW2-vlan2]q
[SW2]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 Eth-
Trunk 0
[SW2-port-group]port link-type trunk
[SW2-port-group]port trunk allow-pass vlan 2
[SW3]vlan 2
[SW3-vlan2]int e0/0/2
[SW3-Ethernet0/0/2]port link-type access
[SW3-Ethernet0/0/2]port default vlan 2
[SW3-Ethernet0/0/2]q
[SW3]int g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2
[SW3-GigabitEthernet0/0/1]int g0/0/2
[SW3-GigabitEthernet0/0/2]port link-type trunk
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[SW4]vlan 2
[SW4-vlan2]int e0/0/2
[SW4-Ethernet0/0/2]port link-type access
[SW4-Ethernet0/0/2]port default vlan 2
[SW4]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[SW4-port-group]port link-type trunk
[SW4-port-group]port trunk allow-pass vlan 2
这时候二三层的交换机都完成VLAN划分创建工作
STP(生成树协议)
根据定义:根网桥上面的接口都是指定端口:因此知道了sw2为根网桥。因为:
在2个三层交换机上面命令查看display stp brief 会发现sw1 上面有一个接口为root 说明sw1 不是根网桥 。而在sw2 上面查看可以看到所有接口都是指定端口,所以这个交换机是根网桥。
但是根据题意如果就只有sw2这个根网桥,所有的流量都会往这个交换机走,但是题目要求的是这2个交换机设备冗。
所有的设备默认都在一个树组里面,所以只会有一个根网桥出现,这时就再在交换机上创建一个组。
解决:让sw1成为组一的根,放VLAN1,成为组2 的备份根。sw2相反
[SW1]stp enable 启动协议
[SW1]stp region-configuration
[SW1-mst-region]region-name a 取个名字
[SW1-mst-region]instance 1 vlan 1 组一放VLAN1
[SW1-mst-region]instance 2 vlan 2
[SW1-mst-region]active region-configuration 激活配置
[SW1-mst-region]q
[SW1]stp instance 1 root primary 该交换机做组一根网桥
[SW1]stp instance 2 root secondary 做组2备份根网桥
[SW2]stp region-configuration
[SW2-mst-region]region-name a
[SW2-mst-region]instance 1 vlan 1
[SW2-mst-region]instance 2 vlan 2
[SW2-mst-region]active region-configuration
[SW2-mst-region]q
[SW2]stp instance 1 root secondary
[SW2]stp instance 2 root primary
[SW3]stp region-configuration
[SW3-mst-region]region-name a
[SW3-mst-region]instance 1 vlan 1
[SW3-mst-region]instance 2 vlan 2
[SW3-mst-region]active region-configuration
[SW4]stp region-configuration
[SW4-mst-region]region-name a
[SW4-mst-region]instance 1 vlan 1
[SW4-mst-region]instance 2 vlan 2
[SW4-mst-region]active region-configuration
查看sw1 发现组一里面sw1是根端口
查看sw2 发现组一里面sw2是根端口
到此stp配置完成,sw1和sw2 互为备份
配置svi
可以让交换机配置ip
[SW1]int Vlanif 1
[SW1-Vlanif1]ip ad 172.16.1.1 25
[SW1-Vlanif1]q
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip ad 172.16.1.129 25
[SW2]int Vlanif 1
[SW2-Vlanif1]ip ad 172.16.1.2 25
[SW2-Vlanif1]q
[SW2]int Vlanif 2
[SW2-Vlanif2]ip ad 172.16.1.130 25
测试ping通
vrrp配置
这个协议配置网关冗余
需要在sw1和sw2上虚拟2个网关
[SW1]int Vlanif 1
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126 VLAN1里面配置虚拟网关ip
[SW1-Vlanif1]vrrp vrid 1 priority 105 改这个虚链路的优先级
开启上行链路追踪,如果 G0/0/24接口坏掉优先级减少10
[SW1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/24 reduced 10
[SW1-Vlanif1]q
[SW1]int vlan 2
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254 VLAN2里面配置虚拟网关ip
[SW2]int Vlanif 1
[SW2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW2-Vlanif1]q
[SW2]int vlan 2
[SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
[SW2-Vlanif2]vrrp vrid 1 priority 105
[SW2-Vlanif2]vrrp vrid 1 track interface g0/0/24 reduced 10
dhcp
[SW1]dhcp enable
[SW1]ip pool 1
[SW1-ip-pool-1]network 172.16.1.0 mask 25
[SW1-ip-pool-1]gateway-list 172.16.1.126
[SW1-ip-pool-1]dns-list 114.114.114.114
[SW1-ip-pool-1]q
[SW1]ip pool 2
[SW1-ip-pool-2]network 172.16.1.128 mask 25
[SW1-ip-pool-2]gateway-list 172.16.1.254
[SW1-ip-pool-2]dns-list 114.114.114.114
[SW1]int Vlanif 1
[SW1-Vlanif1]dhcp select global
[SW1-Vlanif1]q
[SW1]int vlan 2
[SW1-Vlanif2]dhcp select global
[SW2]dhcp enable
[SW2]ip pool 1
[SW2-ip-pool-1]network 172.16.1.0 mask 25
[SW2-ip-pool-1]gateway-list 172.16.1.126
[SW2-ip-pool-1]dns-list 114.114.114.114
[SW2-ip-pool-1]q
[SW2]ip pool 2
[SW2-ip-pool-2]network 172.16.1.128 mask 25
[SW2-ip-pool-2]gateway-list 172.16.1.254
[SW2-ip-pool-2]dns-list 114.114.114.114
[SW2]int Vlanif 1
[SW2-Vlanif1]dhcp select global
[SW2-Vlanif1]q
[SW2]int vlan 2
[SW2-Vlanif2]dhcp select global
最后pc都获得了对应的ip
实验完成