Python 网络运维实验(网络模拟器)
目录
实验环境的搭建 (将ENSP的设备桥接到真实的电脑上)... 3
任务:写实验报告
1.将ENSP的设备桥接到真实的电脑上(先完成)
2.实现telnet(等会讲)
实验环境的搭建 (将ENSP的设备桥接到真实的电脑上)
网络设备:GNS3模拟器上运行华为三层交换机 Cloud
启动ENSP设备
设备的创建 搭建
要求:新建拓扑 对拉设备 加Eth类型端口、加虚拟网卡192.168.56.1,设备的连接 并且启动所有设备 端口映射
1)云的设置
2)对LSW1设备进行配置
system-view
sysname SW1
#
interface Vlanif1
ip address 192.168.56.100 255.255.255.0
对设备的命名 配置管理vlan IP
3)需要将防火墙给关闭了 才能进行ping包
Win+R windows 命令框经行ICMP ping包的操作
思科telnet
拓扑图
- 实现PC ping 通SW
SW(config)#int vlan 1
SW(config-if)#ip add 192.168.56.100 255.255.255.0
SW(config-if)#no sh
- 实现telnet
SW(config)#line vty 0 4
SW(config-line)#login
SW(config-line)#password 123
SW(config-line)#exit
SW(config)#enable password 123
实现ensp 华为telnet ((外连))
LSW1 进行telnet配置.
interface Vlanif1
ip address 192.168.56.100 255.255.255.0
user-interface vty 0 4
user privilege level 15
set authentication password simple Huawei
实现python 登入ensp设备 telnet 并dis cu 输出设备LSW 的所有内容
打开python输入并测试
import telnetlib
import time
host='192.168.56.100'
user='python'
password="huawei"
tn=telnetlib.Telnet(host)
tn.read_until(b"Password:")
tn.write(password.encode('ascii')+b"\n")
tn.write(b'display cu \n')
time.sleep(1)
print(tn.read_very_eager().decode('ascii'))
tn.close()