通过中间文件实现零配置设备部署示例
组网需求
如图3-18所示,在某公司分支机构的部署场景中,新出厂设备SwitchA、SwitchB和SwitchC分别连接到设备SwitchD的GE0/0/1、GE0/0/2和GE0/0/3接口上。SwitchD作为分支机构出口的网关,跨越三层网络与总部相连。
SwitchA、SwitchB和SwitchC因为设备类型不同,所以需要加载不同的系统软件、补丁文件和配置文件。同时,为了降低现场配置的人力成本,用户希望能对这些设备实现远程自动的配置。
- SwitchA:MAC地址为0025-9e1e-773b,需加载的系统软件名为e600_easy_V200R019C10.cc,版本号信息为V200R019C10SPC100,补丁文件为e600_easy_V200R019C10.pat,配置文件为e600_easy_V200R019C10.cfg
- SwitchB:MAC地址为0025-9e1e-773c,需加载的系统软件名为e600_easy_V200R019C10.cc,版本号信息为V200R019C10SPC100,补丁文件为e600_easy_V200R019C10.pat,配置文件为e600_easy_V200R019C10.cfg
- SwitchC:MAC地址为0025-9e1e-773d,需加载的系统软件名为e600_easy_V200R019C10.cc,版本号信息为V200R019C10SPC100,补丁文件为e600_easy_V200R019C10.pat,配置文件为e600_easy_V200R019C10.cfg
配置思路
- 用户PC与SwitchE直接相连,在PC上配置文件服务器。
- 编辑中间文件,实现待配置设备SwitchA、SwitchB和SwitchC通过中间文件获取配置文件、系统软件和补丁文件。
- 将中间文件、系统软件、补丁文件和配置文件放至文件服务器的工作目录下,保证待配置设备能够获取到需要加载的文件。
- 在分支机构网关设备SwitchD上配置DHCP中继;在位于总部的设备SwitchE上配置DHCP服务器。实现DHCP服务器跨网段为待配置设备提供网络配置信息。
- SwitchA、SwitchB和SwitchC上电,实现自动加载配置文件、系统软件和补丁文件。
操作步骤
- 编辑中间文件lswnet.cfg
# 新建一个文本文件,命名为“lswnet.cfg”。中间文件的内容与格式如下:
mac=0025-9e1e-773b;vrpfile=s600-e_easy_V200R019C10.cc;vrpver=V200R019C10SPC100;patchfile=s600-e_easy_V200R019C10.pat;cfgfile=s600-e_easy_V200R019C10.cfg;
mac=0025-9e1e-773c;vrpfile=s600-e_easy_V200R019C10.cc;vrpver=V200R019C10SPC100;patchfile=s600-e_easy_V200R019C10.pat;cfgfile=s600-e_easy_V200R019C10.cfg;
mac=0025-9e1e-773d;vrpfile=s600-e_easy_V200R019C10.cc;vrpver=V200R019C10SPC100;patchfile=s600-e_easy_V200R019C10.pat;cfgfile=s600-e_easy_V200R019C10.cfg;
- 配置文件服务器
请根据文件服务器的操作指导进行配置。
配置完成后,将中间文件、待配置设备需要加载的文件保存至文件服务器中。
- 配置SwitchD
# 配置SwitchD的DHCP中继功能。
<HUAWEI> system-view [HUAWEI] sysname DHCP_Relay [DHCP_Relay] dhcp enable [DHCP_Relay] vlan 10 [DHCP_Relay-vlan10] quit [DHCP_Relay] interface gigabitethernet 0/0/1 [DHCP_Relay-GigabitEthernet0/0/1] port link-type hybrid [DHCP_Relay-GigabitEthernet0/0/1] port hybrid pvid vlan 10 [DHCP_Relay-GigabitEthernet0/0/1] port hybrid untagged vlan 10 [DHCP_Relay-GigabitEthernet0/0/1] quit [DHCP_Relay] interface gigabitethernet 0/0/2 [DHCP_Relay-GigabitEthernet0/0/2] port link-type hybrid [DHCP_Relay-GigabitEthernet0/0/2] port hybrid pvid vlan 10 [DHCP_Relay-GigabitEthernet0/0/2] port hybrid untagged vlan 10 [DHCP_Relay-GigabitEthernet0/0/2] quit [DHCP_Relay] interface gigabitethernet 0/0/3 [DHCP_Relay-GigabitEthernet0/0/3] port link-type hybrid [DHCP_Relay-GigabitEthernet0/0/3] port hybrid pvid vlan 10 [DHCP_Relay-GigabitEthernet0/0/3] port hybrid untagged vlan 10 [DHCP_Relay-GigabitEthernet0/0/3] quit [DHCP_Relay] interface vlanif 10 [DHCP_Relay-Vlanif10] ip address 192.168.1.6 255.255.255.0 [DHCP_Relay-Vlanif10] dhcp select relay [DHCP_Relay-Vlanif10] dhcp relay server-ip 192.168.2.6 [DHCP_Relay-Vlanif10] quit
# 在SwitchD上配置一条静态路由:路由的目的地址为PC的IP地址,下一跳为与SwitchD直连的位于三层网络的设备接口的IP地址。
- 配置SwitchE
# 配置SwitchE的DHCP服务器功能。
<HUAWEI> system-view [HUAWEI] sysname DHCP_Server [DHCP_Server] dhcp enable [DHCP_Server] vlan batch 20 30 [DHCP_Server] interface gigabitethernet 0/0/1 [DHCP_Server-GigabitEthernet0/0/1] port link-type trunk [DHCP_Server-GigabitEthernet0/0/1] port trunk allow-pass vlan 20 [DHCP_Server-GigabitEthernet0/0/1] quit [DHCP_Server] interface gigabitethernet 0/0/2 [DHCP_Server-GigabitEthernet0/0/2] port link-type hybrid [DHCP_Server-GigabitEthernet0/0/2] port hybrid pvid vlan 30 [DHCP_Server-GigabitEthernet0/0/2] port hybrid untagged vlan 30 [DHCP_Server-GigabitEthernet0/0/2] quit [DHCP_Server] interface vlanif 20 [DHCP_Server-Vlanif20] ip address 192.168.2.6 255.255.255.0 [DHCP_Server-Vlanif20] dhcp select global [DHCP_Server-Vlanif20] quit [DHCP_Server] interface vlanif 30 [DHCP_Server-Vlanif30] ip address 192.168.4.1 255.255.255.0 [DHCP_Server-Vlanif30] quit [DHCP_Server] ip pool easy-operation [DHCP_Server-ip-pool-easy-operation] network 192.168.1.0 mask 255.255.255.0 [DHCP_Server-ip-pool-easy-operation] gateway-list 192.168.1.6 [DHCP_Server-ip-pool-easy-operation] option 141 ascii user [DHCP_Server-ip-pool-easy-operation] option 142 cipher huawei [DHCP_Server-ip-pool-easy-operation] option 143 ip-address 192.168.4.6 [DHCP_Server-ip-pool-easy-operation] option 146 ascii opervalue=1;delaytime=0;netfile=lswnet.cfg; [DHCP_Server-ip-pool-easy-operation] quit
# 在SwitchE上配置一条静态路由:路由的目的地址为IP地址池网段,下一跳为与SwitchE直连的位于三层网络的设备接口的IP地址。
- 待配置设备SwitchA、SwitchB和SwitchC上电启动,EasyDeploy流程开始运行
- 验证配置结果
# EasyDeploy流程结束后,登录到待配置设备执行命令display startup查看设备当前的启动系统软件,启动配置文件和启动补丁文件。以SwitchB为例:
<HUAWEI> display startup MainBoard: Configured startup system software: flash:/s600-e_easy_V200R019C10.cc Startup system software: flash:/s600-e_easy_V200R019C10.cc Next startup system software: flash:/s600-e_easy_V200R019C10.cc Startup saved-configuration file: flash:/s600-e_easy_V200R019C10.cfg Next startup saved-configuration file: flash:/s600-e_easy_V200R019C10.cfg Startup paf file: NULL Next startup paf file: NULL Startup license file: NULL Next startup license file: NULL Startup patch package: flash:/s600-e_easy_V200R019C10.pat Next startup patch package: flash:/s600-e_easy_V200R019C10.pat
配置文件
DHCP_Relay的配置文件
# sysname DHCP_Relay # vlan batch 10 # dhcp enable # interface Vlanif10 ip address 192.168.1.6 255.255.255.0 dhcp select relay dhcp relay server-ip 192.168.2.6 # interface GigabitEthernet0/0/1 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # interface GigabitEthernet0/0/2 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # interface GigabitEthernet0/0/3 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # return
DHCP_Server的配置文件
# sysname DHCP_Server # vlan batch 20 30 # dhcp enable # ip pool easy-operation gateway-list 192.168.1.6 network 192.168.1.0 mask 255.255.255.0 option 141 ascii user option 142 cipher %^%#2RC4@B`rZ/{##$1x03%Eh&S.)l7zcQUDl6MLPS"$%^%# option 143 ip-address 192.168.4.6 option 146 ascii opervalue=1;delaytime=0;netfile=lswnet.cfg; # interface Vlanif20 ip address 192.168.2.6 255.255.255.0 dhcp select global # interface Vlanif30 ip address 192.168.4.1 255.255.255.0 # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet0/0/2 port link-type hybrid port hybrid pvid vlan 30 port hybrid untagged vlan 30 # return