华为设备 您所在的位置:网站首页 usg2000配置下发配置慢 华为设备

华为设备

#华为设备| 来源: 网络整理| 查看: 265

实验背景

现有一台华为CE12800交换机,管理IP为为192.168.100.100,利用编写好的python脚本通过NETCONF协议对设备下发配置。

实验环境图1:实验拓扑实验步骤

步骤1:如实验拓扑所示,将CE12800交换机桥接到PC的网卡(192.168.100.1),配置好管理IP地址(192.168.100.100),并测试网络连通性;

图2:CE12800交换机管理IP地址图3:PC与CE12800连通性测试

步骤2:在CE12800交换机上完成NETCONF的相关配置,配置参数如下:

1、使能snetconf功能,并配置用户的服务类型为snetconf、SSH用户认证方式为Password snetconf server enable ssh user netconf ssh user netconf service-type snetconf ssh user netconf authentication-type password 2、AAA配置:配置SSH用户的用户名和密码 aaa local-user netconf password cipher Huawei@123#$ local-user netconf level 3 local-user netconf service-type ssh quit 3、配置SSH服务器端的加密算法列表 ssh server cipher aes128_ctr aes256_ctr aes192_ctr aes128_gcm aes256_gcm 4、配置netconf端口号 netconf protocol inbound ssh port 830 quit 5、commit提交配置 commit

步骤3:测试22端口和830端口是否开启;

图4:测试22端口830端口是否开启

步骤4:编写python代码块;

#模块导入 from ncclient import manager #设备参数 ip = '192.168.100.100' netconf_port = '830' netconf_user = 'netconf' netconf_password = 'Huawei@123#$' #定义函数huawei_connect,用于建立NETCONF连接 def huawei_connect(host,port,user,password): return manager.connect(host=host, port=port, username=user, password=password, hostkey_verify=False, device_params={'name': "huawei"}, allow_agent = False, look_for_keys = False) #NETCONF发送XML数据,配置接口IP地址 CREATE_INTERFACE = """ GE1/0/1 disable GE1/0/1 Config by NETCONF 255.255.255.0 main 192.168.10.10 """ m = huawei_connect(ip, netconf_port, netconf_user, netconf_password) #建立NETCONF连接 m.edit_config(target='running', config=CREATE_INTERFACE) #下发XML数据、配置接口IP地址

步骤五:通过NETCONF下发XMl的数据,对接口 GE1/0/1配置IP地址为:192.168.10.10、端口描述为:Config by NETCONF,然后查看配置是否下发成功;

脚本运行之前,GE1/0/1接口的配置为空脚本运行之后,GE1/0/1接口的配置下发成功



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有