通过使用NETCONF与网管通信示例
在Client端通过网管登录Server,实现远程配置文件管理。
组网需求
当用户希望通过网管统一管理网络设备,需要高安全性、高扩展性时,可选择使用NETCONF保证网管和设备间的通信。
如图17-3所示,在Client端的设备上部署网管系统,Server作为SSH服务器接收作为SSH客户端的Client的链接,从而实现通过NETCONF管理配置文件。而SSH协议是应用层的安全协议,从而提高了NETCONF的可靠性。
本例中interface1代表GigabitEthernet0/0/0。
配置注意事项
本示例以用户client001为例描述,采用Password验证方式对SSH用户进行验证,则需要在Server端生成ECC(Elliptic Curves Cryptography)密钥。
配置思路
采用如下思路配置通过NETCONF管理配置文件的示例:
- 配置Server管理网口的IP地址,实现客户端和服务器之间三层路由可达。
- 配置Server端VTY用户界面支持SSH协议,管理和监控通过SSH协议登录的用户,提高安全连接。
在Server端部署SSH,提高NETCONF协议安全性。
- 创建拥有管理权力的SSH用户。
- 产生ECC密钥对。
- 配置SSH用户认证方式。
- 配置SSH用户服务方式。
- 使能NETCONF功能,允许客户端登录服务器。
- 在Client端部署网管系统,实现客户端可通过网管工具管理网络。
通过网管登录到Server,实现远程配置文件管理。
操作步骤
- 配置Server管理网口的IP地址。
<HUAWEI> system-view [~HUAWEI] sysname netconf-agent [*HUAWEI] commit [~netconf-agent] interface gigabitethernet 0/0/0 [~netconf-agent-GigabitEthernet0/0/0] ip address 10.1.1.1 24 [*netconf-agent-GigabitEthernet0/0/0] commit [~netconf-agent-GigabitEthernet0/0/0] quit
- 配置Server端VTY用户界面支持SSH协议。
[~netconf-agent] user-interface vty 0 4 [*netconf-agent-ui-vty0-4] authentication-mode aaa [*netconf-agent-ui-vty0-4] protocol inbound ssh [*netconf-agent-ui-vty0-4] commit [~netconf-agent-ui-vty0-4] quit
说明:
配置登录协议为SSH,则设备将自动禁止Telnet功能。
- 在Server端部署SSH。
创建SSH用户。
# 新建用户名为Client001的SSH用户,并配置密码为Hello-huawei123。
[~netconf-agent] ssh user client001 [*netconf-agent] aaa [*netconf-agent-aaa] local-user client001 password cipher Hello-huawei123 [*netconf-agent-aaa] local-user client001 user-group manage-ug [*netconf-agent-aaa] local-user client001 service-type ssh [*netconf-agent-aaa] commit [~netconf-agent-aaa] quit
产生ECC密钥对。
[~netconf-agent] ecc local-key-pair create The key name will be: HUAWEI_Host_ECC % ECC keys defined for HUAWEI_Host_ECC already exist. Confirm to replace them? Please select [Y/N]: Y The public key size should be (256/384/521). NOTE: If the key modulus is greater than 256, it will take a few minutes. Input the bits(256/384/521) in the modulus [default = 521] : 256 [*netconf-agent] commit
密钥对生成后,可以执行display ecc local-key-pair public命令查看本地密钥对中的公钥部分信息。
配置SSH用户认证方式。
[~netconf-agent] ssh user client001 authentication-type password [*netconf-agent] commit
配置SSH用户服务方式。
[~netconf-agent] ssh user client001 service-type all [*netconf-agent] commit
- 在Server端使能NETCONF功能。
[~netconf-agent] snetconf server enable [*netconf-agent] commit
- 在Client端部署网管。
网管的安装、操作请参考该软件的安装说明及使用指南。
说明:
若使用华为公司提供的网管系统,创建网元将消耗升级专用项License或网元资源License。若无剩余网元资源License或升级专用项License,则提示创建网元失败,建议申请增加网元资源License或升级专用项License。
- 在Client端通过网管登录Server。
通过网管登录远端设备,请参考该软件的使用指南。
如果使用的是华为公司的网管系统,可联系华为技术工程师提供网管操作手册。
- 验证配置结果
上述配置完成后,可成功通过NETCONF方式登录远端设备实现远程管理配置文件。
说明:
以下配置均在Server(SSH服务器)端执行。
# 执行命令display users,可以看到登录Server的用户信息。
[~netconf-agent] display users User-Intf Delay Type Network Address AuthenStatus AuthorcmdFlag 100 NCA 0 00:02:50 SSH 10.2.2.2 pass yes Username : client001
# 执行命令display ssh user-information,可查看到SSH用户信息。
[~netconf-agent] display ssh user-information -------------------------------------------------------------------------------- User Name : client001 Authentication-Type : password User-public-key-name : - User-public-key-type : - Sftp-directory : - Service-type : snetconf -------------------------------------------------------------------------------- Total 1, 1 printed
# 执行命令display local-user user-group manage-ug,可查看到用户组中本地用户信息。
[~netconf-agent] display local-user user-group manage-ug --------------------------------------------------------------------- Username State Type Access-limit Online --------------------------------------------------------------------- client001 Active S No 1 --------------------------------------------------------------------- Total 1, 1 printed
# 执行命令display ssh server status,可查看到SSH服务器全局配置信息。
[~netconf-agent] display ssh server status SSH Version : 1.99 SSH authentication timeout (Seconds) : 60 SSH authentication retries (Times) : 3 SSH server key generating interval (Hours) : 0 SSH version 1.x compatibility : Enable SSH server keepalive : Disable SFTP server : Disable STELNET server : Disable SNETCONF server : Enable SNETCONF server port(830) : Disable SSH server port : 22 ACL name : ACL number : ACL6 name : ACL6 number : SSH server source address : 0.0.0.0
# 执行命令display netconf capability,可查看到Server支持的能力。
[~netconf-agent] display netconf capability -------------------------------------------------- Capability -------------------------------------------------- urn:ietf:params:netconf:base:1.0 urn:ietf:params:netconf:base:1.1 urn:ietf:params:netconf:capability:writable-running:1.0 urn:ietf:params:netconf:capability:candidate:1.0 urn:ietf:params:netconf:capability:confirmed-commit:1.0 urn:ietf:params:netconf:capability:confirmed-commit:1.1 urn:ietf:params:netconf:capability:rollback-on-error:1.0 urn:ietf:params:netconf:capability:validate:1.0 urn:ietf:params:netconf:capability:validate:1.1 urn:ietf:params:netconf:capability:startup:1.0 urn:ietf:params:netconf:capability:url:1.0?scheme=file,ftp,sftp urn:ietf:params:netconf:capability:xpath:1.0 urn:ietf:params:netconf:capability:notification:1.0 urn:ietf:params:netconf:capability:interleave:1.0 urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=report-all&also-supported=report-all-tagged,trim urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&module-set-id=1903662584 --------------------------------------------------
Server的配置文件
#
sysname netconf-agent
#
aaa
local-user client001 password cipher @%@%U|,(X4rFC)8izE%,QHz:$(|s@%@%
local-user client001 service-type ssh
local-user client001 user-group manage-ug
#
interface GigabitEthernet0/0/0
undo shutdown
ip address 10.1.1.1 255.255.255.255
#
snetconf server enable
ssh user client001
ssh user client001 authentication-type password
ssh user client001 service-type all
#
return