Ensp模拟通过本机(windows)用python脚本批量配置华为数通设备时,为了避免对内网资源的浪费最好用回环口(loopback)。
一、windows开启loopback虚拟接口
概要:
right click on window start menu icon and select Device manager.
click on Action, and select Add legacy hardware (该菜单项或许不会立即显示,要稍后才会显示)
click Next on welcome screen
choose “Install the hardware that i manually select from a list” and click on Next
scroll down and select Network adapters from offered common hardware types and click on Next
select Microsoft as the manufacturer, and then select Microsoft KM-TEST Loopback adapter card model, click on Next
click on Next
click on Finish
详细步骤及截图
1、windows+r键运行hdwwiz
2、添加新硬件
下一步
3、搜索并自动安装硬件
4、找到网络适配器,下一步
5、厂商选择Microsoft,型号选择换回适配器
6、完成,重启电脑生效。
重启电脑后,打开ensp-cloud就可以看到环回网卡了
二、 用windows回环口连接cloud配置
如下图设置,相当于本机电脑的回环网卡连接到了cloud,进而可以在本机通过cli对ensp中的网络设备进行配置,这种连接配置方式为桥接模式。
需注意:下图中169.254.16.38是本机电脑的回环口ip,并不是cloud的ip,cloud只是桥梁
1、配置Cloud所连设备
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]int vlanif 399
Error: The VLAN does not exist.
[Huawei]vlan 399
[Huawei-vlan399]q
[Huawei]int vlanif 399
[Huawei-Vlanif399]ip add 169.254.16.10 16
[Huawei-Vlanif399]q
[Huawei]int gi 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 399
[Huawei-GigabitEthernet0/0/1]q
[Huawei]
[Huawei]stelnet server enable
Info: Succeeded in starting the Stelnet server.
[Huawei]ssh user liulinfeng authentication-type password
Info: Succeeded in adding a new SSH user.
[Huawei]ssh user liulinfeng service-type stelnet
[Huawei]aaa
[Huawei-aaa]local-user liulinfeng password cipher Huawei@123
Info: Add a new user.
[Huawei-aaa]local-user liulinfeng privilege level 15
[Huawei-aaa]local-user liulinfeng service-type ssh
[Huawei-aaa]user-interface vty 0 4
[Huawei-ui-vty0-4]authentication-mode aaa
[Huawei-ui-vty0-4]protocol inbound ssh
[Huawei-ui-vty0-4]q
2、验证本机电脑与ensp中网络设备的连通性
3、通过cloud用电脑ssh登录ensp网络设备
通过windows的cmd访问报错
Microsoft Windows [版本 10.0.22621.819]
(c) Microsoft Corporation。保留所有权利。
C:\Users\liulinfeng>ssh 169.254.16.10
Unable to negotiate with 169.254.16.10 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
C:\Users\liulinfeng>ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 169.254.16.10
Unable to negotiate with 169.254.16.10 port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,des-cbc
C:\Users\liulinfeng>ssh -oKexAlgorithms=+diffie-hellman-group1-sha1=+aes128-cbc=+3des-cbc=+dec-cbc 169.254.16.10
command-line line 0: garbage at end of line; "+aes128-cbc".
C:\Users\liulinfeng>
ensp虚拟的网络设备参数不全,报错正常。
用ssh工具登录可以成功,如下:
登录成功。