配置基础数据


操作场景

用户通过串口登录新交换机,对交换机进行初始化配置。

操作步骤以一个交换机为例说明配置过程。



必备事项

请按照现网网设文档获取交换机的基础配置数据。



操作步骤

1、本地PC使用串口线连接到交换机的Console口。



请使用产品随机附带的Console通信电缆的DB9(孔)插头插入PC机的9芯(针)串口插座,再将RJ-45插头端插入交换机的Console口中。



 说明:

便携计算机通常没有DB-9 COM端口,需要配置USB转COM模块。



图1 通过Console口连接交换机




Java怎么从交换机读数据 交换机写数据_串口


2、使用“PuTTY”工具登录交换机的Console口。在“PuTTY”界面上设置如下登录信息后,单击“Open”。

表1 参数取值

参数

取值

“Connection type”

“Serial”

“Serial line”

根据实际连接的PC串口选择“COM1”、“COM2”或者其他串口。

可以在PC机的“设备管理器 > 端口”查询PC机的串口信息。

若显示不明确,请尝试逐一使用各端口连接。

“Speed”

“9600”


3、可选:设置串口登录密码,仅初次登录交换机时需要设置此密码。

密码为字符串形式,区分大小写,长度范围是8~16。输入的密码至少包含两种类型字符,包括大写字母、小写字母、数字及特殊字符。特殊字符不包括“?”和空格。

An initial password is required for the first login via the console.
Continue to set it? [Y/N]: y
Set a password and keep it safe! Otherwise you will not be able to login via the console.
Please configure the login password (8-16)
Enter Password: //密码为暗文,不在界面显示。
Confirm Password:

4、配置交换机名称和管理IP。

<HUAWEI>system-view #进入系统视图。
[~HUAWEI]sysname S1_LSW_EOR01 #定义交换机名称为S1_LSW_EOR01。
[*HUAWEI]commit #提交。
[~S1_LSW_EOR01]
[~S1_LSW_EOR01]interface meth 0/0/0 #进入“meth 0/0/0”接口视图。
[*S1_LSW_EOR01-MEth0/0/0]ip address 10.1.0.1 255.255.255.0 #设置交换机网关地址和子网掩码分别为10.1.0.1、255.255.255.0。
[*S1_LSW_EOR01-MEth0/0/0]commit #提交配置。
[~S1_LSW_EOR01-MEth0/0/0]return #返回。

5、(可选)配置用户通过Stelnet登录设备。配置用户expert,密码Changeme_123,配置成功后可通过“PuTTY”软件登录交换机管理口。首次使用Stelnet登录设备时,需重新修改密码。仅当现网需要远程访问交换机时,需要配置此信息。

<S1_LSW_EOR01>system-view //进入系统视图。
[~S1_LSW_EOR01]stelnet server enable //开启Stelnet服务功能。
Info: Succeeded in starting the Stelnet server.
[*S1_LSW_EOR01]rsa local-key-pair create //在服务器端生成本地密钥对。
The key name will be: expert_Host
The range of public key size is (512 ~ 2048).
NOTE: Key pair generation will take a short while.
Input the bits in the modulus [default = 2048]:2048 //主机密钥的位数为2048位。
[*S1_LSW_EOR01]user-interface vty 0 4 //进入VTY用户界面视图。
[*S1_LSW_EOR01-ui-vty0-4]authentication-mode aaa //配置VTY用户界面的认证方式为AAA。
[*S1_LSW_EOR01-ui-vty0-4]protocol inbound ssh //配置VTY用户界面支持SSH协议。
[*S1_LSW_EOR01-ui-vty0-4]quit //退出当前操作视图。
[*S1_LSW_EOR01]aaa //进入AAA视图。
[*S1_LSW_EOR01-aaa]local-user expert password irreversible-cipher Changeme_123 //配置本地用户名和密码,expert为用户名,Changeme_123为密码。
Info: A new user is added.
[*S1_LSW_EOR01-aaa]local-user expert level ? //查询用户级别,对于V100R006C00之前版本的交换机,level的范围为0~15;
  INTEGER<0-3>  Value    //对于V100R006C00及之后版本的交换机,当存在command-privilege level配置时,level的范围是0~15,当不存在command-privilege level配置时,level的范围是0~3。
[*S1_LSW_EOR01-aaa]local-user expert level 3 //配置本地用户expert的用户优先级为管理级用户(即上一步命令中查询出的最大值)。
[*S1_LSW_EOR01-aaa]local-user expert service-type ssh //配置本地用户的接入类型为SSH。
[*S1_LSW_EOR01-aaa]quit //退出当前操作视图。
[*S1_LSW_EOR01]ssh user expert authentication-type password //配置SSH用户的认证方式为密码认证。
Info: Succeeded in adding a new SSH user.
[*S1_LSW_EOR01]ssh user expert service-type stelnet //配置SSH用户expert的服务方式为Stelnet。
[*S1_LSW_EOR01]commit //提交配置。

6、(可选)配置交换机时区。仅当现网的时区和默认时区不一致时,需要配置此信息。

clock timezone time-zone-name { add | minus } offset

假设地理位置在北京,设置本地时区名称为BJ。

系统默认的UTC是伦敦时间,在配置时,就是在系统默认的UTC时区的基础上,减去偏移量,才能得到预期的时区,具体配置如下:

<S1_LSW_EOR01>clock timezone BJ add 08:00:00  #设置时区为北京时间。
<S1_LSW_EOR01>clock datetime 0:0:0 2012-12-01 #设置日期为0:0:0 2012-12-01。
<S1_LSW_EOR01>save #保存配置

7、(可选)对接NTP服务器。仅当现网规划了独立的NTP服务器时,需要配置此信息。

对接外部NTP服务器时,通过客户端和服务器端的密码验证(NTP认证),可以保证客户端只与通过验证的设备进行同步,从而提高网络安全性。如果服务器端未配置NTP认证功能,则客户端也不需要配置,两种场景下的具体配置如下:

  • NTP服务器未配置NTP认证功能
<S1_LSW_EOR01>system-view //进入系统视图。
[~S1_LSW_EOR01]ntp unicast-server 10.1.1.1 vpn-instance VRF_OM
//连接外部NTP服务器,10.1.1.1为外部NTP服务器IP地址,此处仅为示例。vpn-instance VRF_OM表示与NTP服务器对接使用的vpn-instance,如果没有,可不添加该参数。
[~S1_LSW_EOR01]commit //提交配置。
  • 服务器端配置了NTP认证功能
<S1_LSW_EOR01>system-view //进入系统视图。
[~S1_LSW_EOR01]ntp authentication enable //使能NTP认证功能。
[*S1_LSW_EOR01]ntp authentication-keyid 42 authentication-mode hmac-sha256 Hello@123456 //配置NTP认证密钥。
[*S1_LSW_EOR01]ntp trusted authentication-keyid 42 //声明可信的密钥。
[*S1_LSW_EOR01]commit //提交配置。
[~S1_LSW_EOR01]ntp unicast-server 10.1.1.1 authentication-keyid 42 vpn-instance VRF_OM//连接外部NTP服务器,并指定使用密钥ID 42加密。
[*S1_LSW_EOR01]commit //提交配置。

8、(可选)配置夏令时。仅当运营商当地需要配置夏令时的时候执行该步骤。


 


  • 夏令时通常只会在一年中的夏季配置,所以夏令时设置间隔不会小于一天且不会大于一年。即,结束时间一定要比开始时间大于一天且不大于一年,才能使得设置生效。
  • 配置周期夏令时,夏令时开始时间和结束时间支持日期+日期、星期+星期两种配置方式。


使用clock daylight-saving-time命令用来配置夏令时。支持以下三种配置:

配置绝对夏令时,仅本年度生效。

clock daylight-saving-time time-zone-name one-year start-time start-date end-time end-date offset

配置周期夏令时,开始时间和结束时间为日期+日期。

clock daylight-saving-time time-zone-name { repeating | repeating } start-time start-date1 end-time end-date1 offset start-year end-year ]]

配置周期夏令时,开始时间和结束时间为星期+星期。

clock daylight-saving-time time-zone-name repeating start-time { first | second | third | fourth | last } weekday month end-time { first | second | third | fourth | last } weekday month offset start-year end-year ]]

假如夏令时时间为NY,那么设置2010-2020间每年一月第一个星期天零点到四月第一个星期天零点设置为夏令时,时间提前一个小时,具体配置如下:

<S1_LSW_EOR01> system-view
[~S1_LSW_EOR01] clock daylight-saving-time NY repeating 0 first sun jan 0 first sun apr 2 2010 2020
[~S1_LSW_EOR01]commit //提交配置。

9、保存交换机配置。


用户通过命令行可以修改设备的当前配置,而这些配置是暂时的,如果要使当前配置在系统下次重启时仍然有效,在重启设备前,需要在用户视图下执行save configuration-file命令将当前配置保存到配置文件中。


<S1_LSW_EOR01>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0...
Save the configuration successfully.