之前项目中经常会涉及到批量配置交换机的场景,现分享给大家。华为交换机 S5700-EI 做为汇聚分载核心流量的模板配置如下(x.x.x.x 为ip, xxxxxxx为密码) : 
sysname xxxx-S5700-EI-1
clock timezone BJ add 08:00:00
ipv6
multicast routing-enable

snmp-agent community read xxxx
snmp-agent sys-info version v2c v3
snmp-agent trap enable

error-down auto-recovery cause bpdu-protection interval 30
error-down auto-recovery cause efm-threshold-event interval 30

dhcp enable

# mstp config
stp enable
stp mode mstp

stp region-configuration
 region-name bj-xxxxx
 revision-level 1
 instance 0 vlan 499 954 955  
 active region-configuration

dhcp server group 1
dhcp-server x.x.x.x

# vlan 933 934 root 
stp instance 0 priority 4096

# inter-vlan
vlan 499
quit

# user-vlan
vlan 954
quit
vlan 955
quit

int ran g0/0/1 to g0/0/24
undo shut
port link-type trunk

int g0/0/1
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-1_x.x.x.x

int g0/0/2
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-2_x.x.x.x

int g0/0/3
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-3_x.x.x.x

int g0/0/4
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-4_x.x.x.x

int g0/0/5
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-5_x.x.x.x

int g0/0/6
undo shut
port trunk allow-pass vlan 499 954
des to xxxx-S5700-LI-6_x.x.x.x

# inter-port
int g0/1/1
undo shut
port link-type trunk
port trunk allow-pass vlan all 
description to xxxx-S5700-24S-1_x.x.x.x

int loopback 0
ip add x.x.x.x 255.255.255.255

int vlanif 1
undo ip add dhcp-all
quit
undo int vl 1

ospfv3 1
router-id x.x.x.x
area 9
stub no-summary

int vl 499
undo shut
ip add x.x.x.x 255.255.255.0
ospf authentication-mode md5 1 cipher bjxxxx
ospf dr-priority 50
ipv6 enable
ipv6 address x:x:x:x:x
ospfv3 1 area 0.0.0.5
ospfv3 dr-priority 220

interface Vlan954
 ipv6 enable
 ip address x.x.x.x 255.255.255.0
 ipv6 address x:x:x:x:x
 undo ipv6 nd ra halt
 ospfv3 1 area 0.0.0.5
 dhcp select relay
 dhcp relay server-select 1
 dhcp relay information enable
 dhcp relay information strategy keep

interface Vlan955
 ipv6 enable
 ip address x.x.x.x 255.255.255.0
 ipv6 address x:x:x:x:x
 undo ipv6 nd ra halt
 ospfv3 1 area 0.0.0.5
 dhcp select relay
 dhcp relay server-select 1
 dhcp relay information enable
 dhcp relay information strategy keep

ospf 86
asbr-summary x.x.x.x 255.255.0.0
asbr-summary x.x.x.x 255.255.255.0
area 9
authentication-mode md5
stub no-summary
network x.x.x.x 0.0.0.255
network x.x.x.x 0.0.255.255

ip route-static 0.0.0.0 0.0.0.0 x.x.x.x
ntp unicast-server x.x.x.x
ntp unicast-server x.x.x.x preference

telnet server enable
aaa
local-user admin password cipher bjxxxxxxx
local-user admin service-type telnet
local-user admin privilege level 15
quit
user-interface vty 0 4
authentication-mode aaa