H3C交换机配置脚本

----------------------------------------------------------------------------------------------------
框式交换机堆叠配置
设备A
system-view
irf member 1
irf-port 2
port group interface hundredgige 3/0/1
port group interface hundredgige 3/0/2
quit
save
chassis convert mode irf

设备B
system-view
irf member 2
irf-port 1
port group interface hundredgige 3/0/1
port group interface hundredgige 3/0/2
quit
save
chassis convert mode irf
再接堆叠线缆
----------------------------------------------------------------------------------------------------
推荐BFD使用管理口;IRF MAC地址滞留;OSPF NON-STOP-ROUTING SNMP-ACL 等部分安全配置
----------------------------------------------------------------------------------------------------
普通交换机堆叠配置  2台交换机通过2个万兆口做堆叠
Device A的配置
system-view
interface ten-gigabitethernet 1/0/1
shutdown
quit
interface ten-gigabitethernet 1/0/2
shutdown
quit
irf-port 1/2
port group interface ten-gigabitethernet1/0/1
port group interface ten-gigabitethernet1/0/2
quit
interface ten-gigabitethernet 1/0/1
undo shutdown
quit
interface ten-gigabitethernet 1/0/2
undo shutdown
quit
irf member 1 priority 32
save force

Device B的成员编号为2,并重启设备使配置生效。
system-view
irf member 1 renumber 2
Warning: Renumbering the switch number may result in configuration change or loss. Continue? [Y/N]:y
quit
reboot
interface ten-gigabitethernet 2/0/1
shutdown
quit
interface ten-gigabitethernet 2/0/2
shutdown
quit
irf-port 2/1
port group interface ten-gigabitethernet2/0/1
port group interface ten-gigabitethernet2/0/2
quit
interface ten-gigabitethernet 2/0/1
undo shutdown
quit
interface ten-gigabitethernet 2/0/2
undo shutdown
quit
save force

连接Device A和Device B之间的IRF端口
[DeviceA] irf-port-configuration active
[DeviceB] irf-port-configuration active

任意一台设备执行 display irf 检查堆叠情况
---------------------------------------------------
接着配置BFD 建议使用管理口配置MAD VLAN 口存在CPU占用率高的问题;并且管理口不占用业务口,非常推荐

#使用管理用以太网口进行BFD MAD检测配置步骤
#在M-GigabitEthernet0/0/0接口上,配置IRF正常工作时,管理员登录IRF使用的IP地址192.168.1.1。
<IRF> system-view
[IRF] interface m-gigabitethernet 0/0/0
[IRF-M-GigabitEthernet0/0/0] ip address 192.169.1.1 24
# 在M-GigabitEthernet0/0/0接口上,分别配置IRF成员设备1和成员设备2的IP地址为192.168.1.101/24和192.168.1.102/24。如果IRF分裂,管理员可以使用192.169.1.101和192.169.1.102分别登录到成员设备1和成员设备2上。
[IRF-M-GigabitEthernet0/0/0] ip address 192.169.1.101 24 irf-member 1
[IRF-M-GigabitEthernet0/0/0] ip address 192.169.1.102 24 irf-member 2
[IRF-M-GigabitEthernet0/0/0] quit
# 配置M-GigabitEthernet0/0/0为MAD保留接口,以使IRF分裂后M-GigabitEthernet0/0/0不会被MAD功能关闭。
[IRF] mad exclude interface m-gigabitethernet 0/0/0
------------------------------------------------------
#使用业务口做BFD  这个VLAN 不要在trunk放行
vlan 3000
name BDF
port gigabitethernet 1/0/24 gigabitethernet 2/0/24
interface vlan-interface 3000
mad bfd enable
mad ip address 10.168.2.1 24 member 1
mad ip address 10.168.2.2 24 member 2
interface gigabitethernet 1/0/1
undo stp enable
interface gigabitethernet 2/0/1
undo stp enable
quit
save fore
连接2台交换机的GI 1/0/1 端口
在任意一台设备上执行<DeviceA> display mad检查MAD配置情况
-------------------------------------------------------------------------------------------------
#基础配置:
system-view
#必须重命名,意义在于使用lldp看到的邻居名称就是系统名称 建议使用物理位置加楼层位置加IP地址命名
sysname FB_15F_CORE_SW

#由于设备根墙的所有逻辑口的MAC地址和虚墙所有接口的MAC地址都是从桥MAC衍生而来,所以一旦堆叠组网的主设备重启,就会造成上述接口的MAC地址改变,从而导致二层网络波动,可能需要等待STP重新收敛,甚至有可能造成直连不通的故障。
irf mac-address persistent always
#登录密码错误延迟60秒重试
attack-defense login reauthentication-delay 60
#在内外部有NTP的情况下强烈建议打开NTP,因为设备产生的日志时间会调用系统时间
clock timezone beijing add 08:00:00
clock protocol ntp
#注意这里的ntp-server 如果交换机配置了DNS则填写NTP服务器域名,比如time.aliyun.com; 如果内网有时钟服务器则配置内网IP;如果交换机自身没有配置DNS则这里需要配置NTP的公网IP
 ntp-service enable
 ntp-service source loopback 0
 ntp-service unicast-server 202.112.29.82

#强烈建议打开交换机这2个功能用于ping和traceroute回包
ip unreachables enable
ip ttl-expires enable

#建议定义2个DNS服务器,交换机定义DNS服务器有2个作用一个是NTP时间服务器查询一个是H3C绿洲云管服务器IP地址查询
#建议使用防火墙或者路由器的DNS代理功能,如果使用DNS代理将可以使用设备的DNS缓存加速和基于DNS的出口负载均衡的功能,而第二DNS可以设置为公网的任意一个DNS服务器
dns server 172.16.0.1
dns server 223.5.5.5

#默认开启,用于交换机邻居发现,相应的命令包括dis lldp nei list / dis lldp nei int gi 1/0/1 verbose
lldp global enable
----------------------------------------------------------------------------------------------------

#建议关闭VLAN1  这是交换机接入端口默认VLAN 不打标签,和控制层报文一样不打标签,建议不把这个VLAN用于生产环境,用于保护控制层报文
interface vlan  1
shutdown

#创建VLAN数据库,这里建议增加name或者description字段,用于描述该VLAN的作用,2选1即可
vlan 81
name OPC_UA_Client
description OPC_UA_Client
----------------------------------------------------------------------------------------------------

#STP强烈建议每台交换机都放置在同一个region里面,默认使用instance0 映射了vlan 1-4094  
stp region-configuration
 region-name zlmc
 active region-configuration
#核心交换机必须增加下面这段配置,一个是声明是instance 0的主根;另外一个是设置TC阈值,防止TC报文频繁刷新MAC地址标项,这个功能默认开启,默认数据是10
 stp instance 0 root primary
 stp tc-protection threshold 5
 stp global enable
#这个功能不建议开启,这个功能配合边缘端口使用,当边缘端口收到BPDU报文后会将端口处于err-down状态
#stp bpdu-protection
#建议打开STP协议的单通检测
stp dispute-protection
#过滤bpdu报文
#stp bpdu-filter
#在接口配置,不能同时配置,不建议配置;根防护在根桥所在交换机接汇聚的物理端口配置;环路保护在非根桥上联根桥端口配置
#interface gi 1/0/1
#在非根桥交换机的根端口和备份端口启用,用于防止根端口和备份端口无法收到上游BPDU转为UP的软故障
stp loop-protection
#在根桥的指定端口启用
stp root-protection
#接入层下联交换机是HUB的情况下,且无法通过STP防环,可以尝试使用loopback-detection 功能找到环路接口
loopback-detection global enale vlan all
loopback-detection global action shutdown
show loopback-detection loop-info
----------------------------------------------------------------------------------------------------
#建议在接入层交换机上打开这个功能,并且指定信任上行端口;强烈不建议在核心交换机上开启该功能
dhcp snooping enable
interface ten 1/0/1
dhcp snooping trust
#核心交换机,内网如果没有DHCP服务器,则开启该功能充当DHCP服务器;但是在IP地址池多的环境下强烈不建议这么做,建议内网部署2台DHCP服务器作主备,来缓解核心压力,并易于管理
dhcp enable
dhcp server forbidden-ip 10.10.1.254

#实例为某个全局IP地址池的配置
dhcp server ip-pool 1
gateway-list 10.10.1.254
network 10.10.1.0 mask 255.255.255.0
dns-list 114.114.114.114
expired day 30
static-bind ip-address 10.10.4.9 mask 255.0.0.0 hardware-address 0148-9ebd-093f-0f
----------------------------------------------------------------------------------------------------
#业务1网关IP
interface Vlan-interface5
description YEWU
 ip address 10.10.1.1 255.255.255.0
  dhcp server apply ip-pool 1

#如果内网有DHCP服务器,则按照如下配置  
interface Vlan-interface21
 description ZLMC-wireless
 ip address 172.23.21.254 255.255.254.0
 dhcp select relay
 dhcp relay dhcp-server timeout 180
 dhcp relay server-address 10.137.221.233
 dhcp relay server-address 10.137.221.234
----------------------------------------------------------------------------------------------------
#接入端口配置示例 (端口范围)
interface range GigabitEthernet1/0/1 to GigabitEthernet1/0/24
description Connect_to_PC
port link-mode bridge
port access vlan 5
stp edged-port

#如果是万兆光转电口,需要指定速率和双工
interface Ten-GigabitEthernet1/0/2
 port link-mode bridge
 description Connect_to_PC
 port access vlan 5
 speed 1000
 duplex full
 stp edged-port

#如果是POE接AP端口,保险起见最好再输入一遍 poe enable 注意其中VLAN 90 是AP的管理VLAN ,这是AP本地转发的典型配置方式;并且如果是combo口默认配置是自动选择;部分V5交换机需要手工配置combo使能端口
interface GigabitEthernet1/0/3
 description AP1-ZhongKong2F
 port link-type trunk
 undo port trunk permit vlan 1
 port trunk permit vlan 2 to 2094
 port trunk pvid vlan 90
 poe enable
 combo enable auto

#Trunk2层互联口典型配置
interface Ten-GigabitEthernet1/0/39
description DownLink_to_HuiJu_Ten1/0/1
 port link-mode bridge
 port link-type trunk
 port trunk permit vlan 10 95

#三层口互联
interface GigabitEthernet1/0/1
 port link-mode route
 description DownLink_HuiJu_Ten1/0/1
 ip address 10.0.0.1 255.255.255.252
#同时写明细路由,推荐如下写法,指定路由出接口和下一条
ip route-static 10.1.0.0 255.255.255.0 GigabitEthernet 1/0/1 10.0.0.2

#典型2层路由聚合组的配置方法,默认聚合模式是on不是动态聚合link-aggregation mode dynamic 这个命令可以不用敲
interface Bridge-Aggregation1
description Connect_to_AC+AP
port link-type trunk
port trunk permit vlan 2 4
link-aggregation mode dynamic

#定义聚合组1的成员端口
interface GigabitEthernet1/0/23
description Connect_to_AC+AP
port link-mode bridge
port link-type trunk
port trunk permit vlan 2 4
port link-aggregation group 1

interface GigabitEthernet2/0/23
description Connect_to_AC+AP
port link-mode bridge
port link-type trunk
port trunk permit vlan 2 4
port link-aggregation group 1

#典型3层路由聚合口配置方法,无论是3层聚合口互联口还是3层互联口的IP掩码建议改为30位掩码
interface Route-Aggregation6
 ip address 172.23.99.62 255.255.255.252
interface Ten-GigabitEthernet1/0/45
 port link-mode route
 port link-aggregation group 6
----------------------------------------------------------------------------------------------------
#配置管理 打开你需要的远程管理方式 这里推荐打开SSH 和 HTTPS 并调用ACL限定能够访问的内网IP地址
ssh server enable
ssh server acl 2000
telnet server enable
telnet server acl 2000
ip https enable
ip https acl 2000
#
acl basic 2000
 rule 0 permit source 10.137.221.122 0
 rule 1 permit source 10.137.221.186 0
 rule 5 permit source 10.137.221.10 0
 rule 10 deny
#创建管理员 指定访问方式和权限 指定密码 密码重试次数 密码策略
local-user admin class manage
 password-control length 8
 password-control login-attempt 10
 password simple abcd1234
 service-type http https ssh terminal
 authorization-attribute user-role network-admin
#终端配置 包括虚拟终端和aux 也就是console口 使用系统内置账号登录 仅允许角色为network-admin账号登录(默认账号为network-operator),超时时间为30分钟   aux这段也可以不配置
line vty 0 63
 authentication-mode scheme
 user-role network-admin
 protocol inbound all
 idle-timeout 30 0
line aux 0
 authentication-mode scheme
 user-role network-admin
 idle-timeout 30 0
 
#如果设备要上云管 特别是AC 则建议配置H3C云管 同时需要设备配置DNS服务器
cloud-management server domain oasis.h3c.com
----------------------------------------------------------------------------------------------------  
#设置策略路由,出外网优先走电信线路,注意这里需要将内网互访流量排除,剩余访问互联网的流量做测量路由 这里1.1.1.1 假设为电信出口对端IP
acl advanced 3000
rule permit ip source 10.10.2.0 0.0.0.255
quit

acl advanced 3001
rule permit ip source 10.10.2.0 0.0.0.255 destination 10.10.1.0 0.0.0.255
quit

acl advanced 3002
rule permit ip source 10.10.2.0 0.0.0.255 destination 10.10.3.0 0.0.0.255
quit

acl advanced 3003
rule permit ip source 10.10.2.0 0.0.0.255 destination 10.10.4.0 0.0.0.255
quit

policy-based-route TO_DIANXIN permit node 10
if-match acl 3001
quit
policy-based-route TO_DIANXIN permit node 20
if-match acl 3002
quit
policy-based-route TO_DIANXIN permit node 30
if-match acl 3003
quit
policy-based-route TO_DIANXIN permit node 40
if-match acl 3000
apply next-hop 1.1.1.1 track 1
quit

#配置NQA和TRACK 并调用在静态路由和策略路由上特别注意 这里Next-hop 下一跳IP必须是对端公网出口IP;并且PING测试的公网IP必须稳定,经过测试不能使用114 也不推荐使用公网出口对端IP;这里假设1.1.1.1为电信出口对端IP   2.2.2.2 为移动出口对端IP
nqa entry admin wan1
type icmp-echo
destination ip 223.5.5.5
next-hop ip 1.1.1.1
frequency 100
reaction 1 checked-element probe-fail threshold-type consecutive 10 action-type trigger-only
quit

nqa schedule admin wan1 start-time now lifetime forever

track 1 nqa entry admin wan1 reaction 1

nqa entry admin wan2
type icmp-echo
destination ip 223.5.5.5
next-hop ip 2.2.2.2
frequency 100
reaction 2 checked-element probe-fail threshold-type consecutive 10 action-type trigger-only
quit

nqa schedule admin wan2 start-time now lifetime forever

track 2 nqa entry admin wan2 reaction 2

#主用走移动链路上网,备用走电信线路
ip route-static 0.0.0.0 0.0.0.0 1.1.1.1 track 1 description zhuyuong_dianxin
ip route-static 0.0.0.0 0.0.0.0 2.2.2.2 10 track 2 beiyong_yidong


#interface gi 1/0/1
description To_CoreSW
ip addess 172.23.97.250
nat hairpin enable
manage https inbound
manage ping inbound
manage ssh inbound
ip policy-based-route TO_DIANXIN
----------------------------------------------------------------------------------------------------
acl advanced 3000
 description Ban_wifi_guest
 rule 0 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.2.0 0.0.0.255
 rule 5 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.4.0 0.0.0.255
 rule 10 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.6.0 0.0.0.255
 rule 15 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.18.0 0.0.0.255
 rule 20 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.20.0 0.0.0.255
 rule 25 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.30.0 0.0.0.255
 rule 30 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.50.0 0.0.0.255
 rule 35 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.60.0 0.0.0.255
 rule 40 deny ip source 10.88.40.0 0.0.0.255 destination 10.88.0.0 0.0.0.255
 rule 45 permit ip

#
interface Vlan-interface40
 description WIFI-GUEST
 ip address 10.88.40.254 255.255.255.0
 packet-filter 3000 outbound
 dhcp server apply ip-pool vlan40

----------------------------------------------------------------------------------------------------

#配置snmp
snmp-agent-savd
 snmp-agent community read Admin@123. acl 2000
 snmp-agent community write Admin@123 acl 2000
 snmp-agent sys-info version all
 snmp-agent target-host trap address udp-domain 10.137.221.222 params securityname zlmc v2c
 snmp-agent trap enable arp
 snmp-agent trap enable stp
 snmp-agent trap enable syslog
----------------------------------------------------------------------------------------------------
#配置远程镜像  这种适合缺少光电转换模块 或者光电转换模块使用后没有流量的情况 将镜像流量放入特定VLAN 送给其他交换机;需要特别注意 这个VLAN必须要在其余TRUNK口剔除!
 vlan 5
 description r-mirror
 mirroring-group 1 remote-source
 mirroring-group 1 remote-probe vlan 5
#定义需要镜像流量的端口
interface Ten-GigabitEthernet1/0/41
 port link-mode route
 mirroring-group 1 mirroring-port both
#远程镜像流量的入接口,送给下一台交换机的接口,需要放通VLAN5
interface Ten-GigabitEthernet1/0/8
 port link-mode bridge
 description Link-to-IDS
 port link-type trunk
 port trunk permit vlan all
 undo stp enable
 mirroring-group 1 monitor-egress
#流量目的交换机上面配置  以下是另外一台交接机上面的配置
 mirroring-group 1 remote-destination
 mirroring-group 1 remote-probe vlan 5
#流量观察端口
interface GigabitEthernet1/0/21
 description connect_to_tianrongxing_taishiganzhi
 port access vlan 5
 combo enable auto
 undo stp enable
 mirroring-group 1 monitor-port
----------------------------------------------------------------------------------------------------
#配置本地镜像 用于简单的镜像分析
 mirroring-group 2 local
#
interface Ten-GigabitEthernet1/0/4
 port link-mode bridge
 description connect_to_FW
 port access vlan 97
 mirroring-group 2 mirroring-port both
#
interface Ten-GigabitEthernet1/0/44
 port link-mode bridge
 description Link-to-ids
 undo stp enable
 mirroring-group 2 monitor-port
----------------------------------------------------------------------------------------------------
#配置配置文件定时备份任务 我这里配置了一个每周六定时保存配置 保存配置文件到FTP文件服务器的任务
#
scheduler job saveconfig
 command 1 save force
 command 2 copy startup.cfg ftp://ftpuser:Admin@123.@10.137.223.200/172.23.99.1.conf
#
scheduler schedule saveconfig
 user-role network-admin
 job saveconfig
 time repeating at 12:01 week-day Sat
#

#配置log  这里严重界别定义为local5
info-center loghost 10.137.221.100 facility local5  

----------------------------------------------------------------------------------------------------
#配置OSPF  记得 需要配置loopback接口 掩码是32位  然后指定route-id为loopback IP   如果是核心连出口设备则导入静态路由 配置静默端口,否则用户网段会收到OSPF组播,配置区域认证,将loopback ip 3层互联口ip  以及业务IP地址宣告;在三层互联口将网络类型改为P2P加快邻居关系建立
interface LoopBack0
 ip address 172.23.99.1 255.255.255.255
 
ospf 1 router-id 172.23.99.1
non-stop-routing
 default-route-advertise
 import-route static
 silent-interface Vlan-interface80
 area 0.0.0.0
  authentication-mode md5 1 Admin@123
  network 172.23.1.0 0.0.0.255
  network 172.23.99.1 0.0.0.0
  network 172.23.99.60 0.0.0.3
 
interface Route-Aggregation6
 ip address 172.23.99.62 255.255.255.252
 ospf network-type p2p
----------------------------------------------------------------------------------------------------
#一定要记得在配置完成之后使用这2条命令关闭debug 并保存配置
undo debug all
save force
-----------------------------------------------------------------------------------------------------
配置完成之后需要检查的项目包括:
1、检查光模块收发光功率
display transceiver diagnosis interface
如果在阈值外需要调整
display transceiver alarm interface
如果有告警需要调整
2、检查电源模块
display power
display power-supply verbose
3、检查软件版本
display version  
将系统升级到最新版本并打上补丁
步骤如下:https://www.h3c.com/cn/Service/Document_Software/Document_Center/Home/Switches/00-Public/Quick_Starts/Quick_Maintenance/H3C_CLI_IQG-6W100/?CHID=357086
4、STP边缘端口检查
display stp
display current-configuration
5、Flash卡未使用文件检查
dir
6、STP非正常阻塞端口检查
display stp brief
display stp abnormal-port
7、防火墙全通安全策略检查
display current-configuration
8、OSPF错误统计检查
display ospf error
display ospf statistics error
9、irf链路状态信息检查
display irf configuration
10、堆叠口UP DOWN检查
display irf topology
display irf configuration
11、聚合组成员端口选中状态检查
display link-aggregation summary
display link-aggregation verbose
12、检查irf设备是否开启了桥MAC保留命令配置
display current-configuration
确认现场配置了IRF,可以检查配置中是否有“irf member 1 priority xx”或者“irf member 2 priority xx”,如果有说明设备是IRF组网。然后确认设备上是否有“irf mac-address persistent always”配置,如果没有则告警
13、SNMP团体ACL访问控制检查
display current-configuration
14、VTY用户访问权限安全性检查
display current-configuration
15、Login用户登录失败延迟检查
display current-configuration
attack-defense login reauthentication-delay xxx
16、缺省账号检查
为减少设备登录被暴力破解的可能,应删除设备的缺省登录用户名(admin/h3c/root)。
display current-configuration
17、关闭网络服务检查
关闭网络设备不必要的服务,比如:ftp,http,https等,建议用户根据自身需求,选择性关闭。
display current-configuration
18、端口错包统计检查
display interface
19、检查配置是否保存
dis cur configuration
dis savd configuration
20、检查日期和时间
dis clock
21、检查路由表和邻居表
dis lldp nei list
dis ip routing-table
22、检查二层和3层端口状态
dis int brie
dis ip int brie
-----------------------------------------------------------------------------------------------------
2环路和接口丢包错包排查相关命令
terminal monitor

dis int brie
dis interface | inc UP
dis interface link-info

dis counters inbound interface
dis counters outbound interface
dis counters rate inbound interface
dis counters rate outbound interface

dis mac-address mac-move

loopback-detection global enable
loopback-detection action shutdown
dis loopback-detection

dis stp brie
dis vlan

dis qos policy

lldp enable
dis lldp nei brie
dis link-aggregation verbose

dis logbuffer
主机PING 出现DUP 字段告警;抓包出现大量广播报文

2层环路 主要原因是未配置STP  安全设备过滤了STP报文  傻瓜式交换机过滤了STP报文  聚合组成员端口接错导致的单通阻塞 接入层交换机底下的傻瓜式交换机成环,这个情况下需要使用loopback-detection功能检测
-----------------------------------------------------------------------------------------------------
3层环路
1、直连丢包,检查ARP标项是否稳定学习到(观察ARP老化时间)
2、如果是非直连丢包,检查路由标项和下一跳ARP标项是否是否稳定的学习到,若都没有则确认丢包位置再确认原因
3、检查表项是否都正常,如果标项均正常依旧无法互通,此时建议抓包确认报文内容,检查报文的目的MAC是否封装错误等,交换机查找三层标项的基础是接口是三层接口及数据报文的目的MAC为本机的三层接口MAC
4、确认都正常后已经无法互通,此时联系后台研发确认是不是交换机内存芯片等转发异常。
dis ip routing-table x.x.x.x
dis arp x.x.x.x
主机表现为ttl 超时 使用traceroute 能够看到路由环路发生的位置
路由环路一般是因为路由汇总 路由引入错误导致
-----------------------------------------------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值