1、核心层功能配置

1.1 VSF虚拟化

1.1.2用户场景

两台核心交换机采用VSF虚拟化方式部署,将2台核心交换机逻辑上虚拟为单台设备,方便管理,同时实现冗余负载。

1.1.2.1交换机相关配置

VSF配置:

!!
switch convert mode vsf
vsf member 2
vsf priority 32
vsf port-group 1
 vsf port-group Interface Ethernet2/7/50
!
vsf port-group 2
 vsf port-group Interface Ethernet2/3/50
!
vsf auto-merge enable //使能 VSF 组自动合并功能
vsf link delay 2000 //配置 VSF 链路 down 延迟上报功能,用于避免因端口链路层状态在短时间内频繁改变,导致VSF 分裂、合并的频繁发生。
vsf mac-address persistent always //配置 VSF 分裂后 VSF 组 MAC 地址保留时间
!!
!
BFD检测配置:
!
vlan 4000
 name vsf
!
Interface Ethernet1/7/48
 description VSF_BFD
 switchport access vlan 4000
!
!
Interface Ethernet2/7/48
 description VSF_BFD
 switchport access vlan 4000
!
!
interface Vlan4000
 vsf mad bfd enable
 vsf mad ip address 200.1.1.1 255.255.255.248 member 1
 vsf mad ip address 200.1.1.2 255.255.255.248 member 2
!
1.2 MSTP+VRRP 双机冗余热备
两台核心交换机,通过MSTP+VRRP技术,实现核心交换机的双机热备和流量负载。
1.2.1 SW1配置
1.2.1.1 MSTP配置
!
spanning-tree mst configuration
 name nepc
 instance 0 vlan 1-62;64-71;73-77;79-800;802-999;1001-1099;1101-1199;1201-1999;2001-2099;2101-2199
 instance 0 vlan 2201-3099;3101-3199;3201-3299;3301-4094
 instance 1 vlan 63;72;78;801;1000;1100;1200;2000;2100;2200;3100;3200;3300
 exit
!
spanning-tree
spanning-tree tcflush protect
spanning-tree mst 0 priority 0
spanning-tree mst 1 priority 4096
!
1.2.1.2 VRRP配置(部分)
!
router vrrp 1
 virtual-ip 10.162.1.1
 interface Vlan100
 priority 150
 advertisement-interval 5
 enable
!
router vrrp 21
 virtual-ip 10.162.63.1
 interface Vlan63
 advertisement-interval 5
 preempt-mode false
 enable
1.2.2 SW2配置
1.2.2.1 MSTP配置
!
spanning-tree mst configuration
 name nepc
 instance 0 vlan 1-62;64-71;73-77;79-800;802-999;1001-1099;1101-1199;1201-1999;2001-2099;2101-2199
 instance 0 vlan 2201-3099;3101-3199;3201-3299;3301-4094
 instance 1 vlan 63;72;78;801;1000;1100;1200;2000;2100;2200;3100;3200;3300
 exit
!
spanning-tree
spanning-tree tcflush protect
spanning-tree mst 0 priority 4096
spanning-tree mst 1 priority 0
!
1.2.2.2 VRRP配置(部分)
!
router vrrp 1
 virtual-ip 10.162.1.1
 interface Vlan100
 advertisement-interval 5
 preempt-mode false
 enable
!        
router vrrp 21
 virtual-ip 10.162.63.1
 interface Vlan63
 priority 150
 advertisement-interval 5
 enable
!
*同一个MSTP域中的设备,Vlan信息和MSTP配置信息(名称、实例Vlan对应关系)必须保持一致,否则MSTP无法正常运行。
2、汇聚层功能配置
2.1 MSTP生成树配置(配合1.2)
!        
spanning-tree mst configuration
 name nepc
 instance 0 vlan 1-1099;1101-1199;1201-1999;2001-2099;2101-2199;2201-3099;3101-3199;3201-3299;3301-4094
 instance 1 vlan 1100;1200;2000;2100;2200;3100;3200;3300
 exit
!
spanning-tree
spanning-tree tcflush protect
!
*设置传播拓扑改变消息时进行 FLUSH的模式,协议要求是每次拓扑改变都FLUSH,但在实际环境中,可能不需要也不希望有过多的刷新造成流量不稳定,因此允许根据实际环境设置不同的处理方式, disable 表示不因拓扑改变而刷新, protect 表示每 10 秒最多进行一次刷新,以避免拓扑改变攻击造成的过多刷新。
3、接入层功能配置
3.1单端口环路检测
全局模式下配置:
#单端口环路检测报文的发送间隔(有环路时35秒发送1次,没有环路时15秒发送1次)
!
loopback-detection interval-time 35 15
!
#打开单端口环路ShutDown自动恢复功能,恢复时间为300秒
loopback-detection control-recovery timeout 300
!
接口模式下配置:
#端口打开单端口环路检测功能,控制模式为ShutDown
!
Interface Ethernet1/0/1
 switchport access vlan 11
 loopback-detection specified-vlan 11
 loopback-detection control shutdown
!
*单端口环路检测在必须要在端口开启。同时,必须要指定检测那个Vlan内的环路,此功能才可生效
*端口控制模式是“ShutDown”时,需要全局打开恢复功能。默认ShutDown的端口不会自动恢复
3.2 AM端口绑定
3.2.1 端口下终端IP绑定
3.2.1.1用户需求
用户处网络终端IP地址手动分配,为防止终端用户私自更改IP地址造成IP地址冲突,需要在接入交换机上启用am功能,实现终端用户只能使用特定IP地址上网,私自修改其他IP后将无法访问网络。
3.2.1.2具体配置
全局模式下配置:
!
am enable
!
接口模式下配置:
!
Interface Ethernet1/0/1
 switchport access vlan 78
 am port
 am ip-pool 10.162.78.107 1
!
3.2.2 端口下终端IP+MAC绑定
3.2.2.1用户需求
用户为实现终端安全接入,需要在交换机上对终端的IP、MAC地址进行绑定,实行严格的接入控制。
3.2.2.2具体配置
全局配置下模式:
!
am enable
!
接口配置模式下配置:
!
Interface Ethernet1/0/22
 switchport access vlan 11
 loopback-detection specified-vlan 11
 loopback-detection control shutdown
 am port
 am mac-ip-pool 18-66-da-38-ab-65 10.10.11.18
!
3.3 IP DHCP SNOOPING 配置
全局模式下配置:
!
ip dhcp snooping enable
!
上联端口配置:
!
Interface Ethernet1/0/50
 speed-duplex auto
 switchport mode trunk
 ip dhcp snooping trust
!
3.4 POE交换机
3.4.1监控端口统计信息
通过监控端口统计信息,在AP发生死机情况下,可实现对AP的断电重启。
!
Interface Ethernet1/0/2
 storm-control broadcast 50000
 switchport access vlan 20
 power inline monitor on
!
3.4.1POE与ImCloud对接
4、其他配置
4.1 SNMP配置
!
snmp-server enable
snmp-server securityip 10.10.98.88
snmp-server community ro 7 wFbcsoAfrRQ=
snmp-server community rw 7 ZwQTWAGCWfc=! 
!
4.2 日志配置
!
logging 10.10.100.195  //日志服务器地址
logging executed-commands enable //打开记录用户执行命令的日志开关
!
4.3 NTP配置
4.1.1 用户需求
交换机时间定期与ntp服务器同时,设置对应时区。
4.1.2 具体配置
!
clock timezone beijing add 8 0  //配置时区
!
ntp enable
ntp syn-interval 30  //配置同步时间间隔
ntp server 202.112.10.60  //NTP服务器IP地址
!
4.4 安全管理地址配置
authentication securityip 10.10.10.11  //一般为堡垒机地址
4.5 登录超时配置
exec-timeout 5 0  //超时退出
4.6 PBR引流配置
PBR(Policy-Based Routing,策略路由) 是根据 IP 包的源地址、目的地址、 IP 优先级、 TOS 值、 IP 协议、源端口号、目的端口号等信息来策略性的指定数据包转发的下一跳的一种方法。
4.6.1用户需求
防火墙旁路部署,需要对终端访问服务器的流量进行安全防护。
4.6.2具体配置(测试配置)
!
vlan 2000
 name client-server
!
vlan 2001
 name server-client
!
vlan 2002
 name test-client
!
vlan 2003
 name test-server
!
ip access-list extended toserver
  permit ip 10.20.202.0 0.0.0.255 10.20.203.0 0.0.0.255
ip access-list extended toclient
  permit ip 10.20.203.0 0.0.0.255 10.20.202.0 0.0.0.255
!
#配置一个 class-map(分类表)
class-map toclient
#设置分类表中的匹配标准。
!
class-map toserver
 match access-group toserver
!
#建立一个 policy-map(策略表)。
!
policy-map toserver
#配置一个策略表对应一个 class(分类表)
#为分类后的流量设置下一跳 IP
 exit
!
policy-map toclient
 class toclient
 set ip nexthop  10.20.201.2
 exit
!
service-policy input toserver vlan 2002 #在具体 VLAN 上绑定策略表
service-policy input toclient vlan 2003
!
interface Vlan2000
 ip address 10.20.200.1 255.255.255.0
!
interface Vlan2001
 ip address 10.20.201.1 255.255.255.0
!
interface Vlan2002
 description test-client
 ip address 10.20.202.1 255.255.255.0
!
interface Vlan2003
 description test-server
 ip address 10.20.203.1 255.255.255.0
!        
4.6.2测试验证
PC1(模拟客户端)10.20.202.2
PC2(模拟服务器)10.20.203.2
在PC1上通过tracert命令对PC2 IP地址做路由跟踪,观察路由路径。
4.6.2.1 引流启用之前
PC1访问PC2流量直接经过三层交换机进行转发,转发路径为:终端-三层交换-服务器。
4.6.2.2 引流启用之后
PC1访问PC2流量到达三层交换机后,又经防火墙进行转发,转发路径为:终端-三层交换-防火墙-三层交换-服务器。
*目前策略表只支持绑定到入口,对出口不支持。
*受硬件资源限制,如果策略过于复杂,配置不上,会提示用户相关信息。
4.7 使用RSPAN实现1:N镜象(多个镜像目的端口)
4.7.1用户需求
用户已经通过端口镜像的方式,将全网流量镜像至态势感知设备,用于网络安全分析;目前,用户又增加网络准入设备,也需要将全网流量镜像至该设备,实现对未认证终端设备网络访问流量的阻断。需要实现1:N镜像。
4.7.2具体配置
交换机为VSF模式部署,由于VSF虚拟化场景不能跨设备进行流量镜像,所以创建2个镜像会话。
#配置RSPAN使用的远程Vlan
!
vlan 4090
 remote-span
!
vlan 4091
 remote-span
!
!
#配置镜象的源端口
monitor session 1 source interface Ethernet1/0/1;1/0/3;1/0/5;1/0/7;1/0/9;1/0/13;1/0/15;1/0/17 tx
monitor session 1 source interface Ethernet1/0/1;1/0/3;1/0/5;1/0/7;1/0/9;1/0/13;1/0/15;1/0/17 rx
monitor session 2 source interface Ethernet2/0/1;2/0/3;2/0/5;2/0/7;2/0/9;2/0/13;2/0/15;2/0/17 tx
monitor session 2 source interface Ethernet2/0/1;2/0/3;2/0/5;2/0/7;2/0/9;2/0/13;2/0/15;2/0/17 rx
#指定RSPAN的反射端口
monitor session 1 reflector-port Ethernet 1/0/34
monitor session 2 reflector-port Ethernet 2/0/34
monitor session 1 remote vlan 4090
monitor session 2 remote vlan 4091
!
!
Interface Ethernet1/0/34  //反射端口
 switchport access vlan 4090
Interface Ethernet1/0/31  //镜像目的端口1
 speed-duplex force1g-full
 switchport access vlan 4090
!
Interface Ethernet1/0/33  //镜像目的端口2
 speed-duplex force1g-full
 switchport access vlan 4090
!
Interface Ethernet2/0/34  //反射端口
 switchport access vlan 4091
!
Interface Ethernet2/0/31  //镜像目的端口1
 speed-duplex force1g-full
 switchport access vlan 4091
!
Interface Ethernet2/0/33  //镜像目的端口2
 speed-duplex force1g-full
 switchport access vlan 4091
!

*使用RSPAN实现的1:N镜象配置中必须要有1个端口做为反射端口。反射端口只能发出镜象的流量,而不可以接收流量。

*如果有更多端口需要接收镜象流量,将这些端口做为ACCESS端口加入远程Vlan即可。

*使用这样的方式,会在远程Vlan中产生大量的镜象流量。在使用过程中,对于不希望接收镜象流量的Trunk端口,可以将远程Vlan从Trunk端口中排除掉。