实验1 修改loopback0地址
实验拓扑
config:
aaa
local-user python password cipher 123asd
local-user python privilege level 3
local-user python service-type sshstelnet server enable
ssh authentication-type default passworduser-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
screen-length 0
192.168.8.0/24 ⽹段我⾃⼰的电脑(Win10 已安装 python 3.9.3)设置⼀块虚拟⽹卡地址为 192.168.8.105/24,桥接,与实验拓扑拉通组⽹。
本次实验只需要⽤到 PC ,透明交换机SW1(启动即可,⽆需配置)、LSW1(Python 第三⽅库 paramiko 要操控的设备。),其它 LSW未启动,后续实验再使⽤。
⽤Python Paramiko 模块实现 SSH 登陆单个交换机LSW1(192.168.8.201),为其 LoopBack0 端⼝配置IP地址 1.1.1.1 /32。配置完成后对设备进⾏配置保存,并退出。
检查⽹络连通性(PC ping 测 192.168.201),打开 cmd,执⾏ ping 192.168.8.201
检查 win10 的 arp 表项,打开 cmd ,执⾏ arp -a ,找到 接⼝: 192.168.8.201 — 0x10 查看表项。
import paramiko
import time
ip = "192.168.8.201"
username = "python"
password = "123asd"
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip, username=username, password=password, look_for_keys=False)
print("Successfully connected to ", ip)
command = ssh_client.invoke_shell()
command.send("sys\n")
command.send("interface LoopBack 0\n")
command.send("ip address 1.1.1.1 255.255.255.255\n")
command.send("return\n")
command.send("save\n")
command.send("y\n")
time.sleep(3)
command.send("display this\n")
time.sleep(1)
output = command.recv(65535)
print(output.decode("ascii"))
ssh_client.close()
输出
C:\Users\82127\.conda\envs\pythonProject\python.exe E:\log\python\pythonProject\Demo01.py
Successfully connected to 192.168.8.201Info: The max number of VTY users is 5, and the numberof current VTY users on line is 1.The current login time is 2022-05-30 22:54:56.
<LSW1>sys
Enter system view, return user view with Ctrl+Z.
[LSW1]interface LoopBack 0
[LSW1-LoopBack0]ip address 1.1.1.1 255.255.255.255
[LSW1-LoopBack0]return
<LSW1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:display this
Error: Invalid file name or Invalid extension ( *.cfg, *.zip ).
<LSW1>
实验1 修改loopback0地址相关推荐
- Linux 修改 IP地址 和 网关
修改IP地址和网关是很常见的操作,在做相关实验的时候,如果没有设置好,会带来很多不必要的麻烦.. 1. 修改IP地址 vi /etc/sysconfig/network-scripts/ifcfg-e ...
- 无盘服务器怎么修改ip,怎么进入无盘服务器修改IP地址呢
怎么进入无盘服务器修改IP地址呢 内容精选 换一换 在弹性云服务器上安装完成后输入公网IP,无法连接目的虚拟机,端口无法访问工具.源端网络未连通目的端.目的端安全组未开放8084端口.目的端网络ACL ...
- 服务器修改虚拟机地址,服务器修改虚拟机地址
服务器修改虚拟机地址 内容精选 换一换 在华为云上安装完成后输入公网IP,无法连接目的虚拟机,端口无法访问工具.源端网络未连通目的端.目的端安全组未开放8082端口.目的端网络ACL禁用了8082端口 ...
- ubuntu18.04修改mac地址
一.关闭网卡设备 sudo ifconfig eno1 down 其中eth0是要修改mac地址网卡的名称,并非所有的网卡命名都是按照eth0.eth1来命名的,因此需要查看自己网卡名称,输入命令if ...
- java 网关ip_Linux 修改IP地址和网关
修改IP地址和网关是很常见的操作,在做相关实验的时候,如果没有设置好,会带来很多不必要的麻烦. 1. 修改IP地址 vi /etc/sysconfig/network-scripts/ifcfg-et ...
- python修改ip地址_怎么更改电脑ip地址?基于 Python 爬虫的ip修改设计与实现
怎么更改电脑ip地址?基于 Python 爬虫原理的篮球鞋选择程序的设计与实现ip修改 [摘 要]伴随着篮球鞋工艺的进步及产业升级,多类型多种类的篮球鞋出现在大众的视野当中.与此同时,消费者对篮球鞋的 ...
- Linux修改IP地址和网关
原 Linux 修改 IP地址 和 网关https://blog.csdn.net/tianlesoftware/article/details/5312646版权声明: https://blog.c ...
- linux oracle 更换ip,Linux 修改IP地址和网关
修改IP地址和网关是很常见的操作,在做相关实验的时候,如果没有设置好,会带来很多不必要的麻烦. 1. 修改IP地址 vi /etc/sysconfig/network-scripts/ifcfg-et ...
- 税友报税软件让修改服务器地址,税友报税软件让修改服务器地址
税友报税软件让修改服务器地址 内容精选 换一换 目前,支持通过以下2种方式来设置日志级别:通过执行命令来设置日志级别.您可以用adc进程运行用户登录开发环境,执行全局级或模块级的日志级别设置命令.在开 ...
最新文章
- C语言中两种方式表示时间日期值time_t和struct tm类型的相互转换
- ubuntu设置root用户密码
- python 返回函数对象_返回函数
- 贡献一个连jquery都觉的大的时候可以用的 js库
- python读写excel模块pandas_Python3使用pandas模块读写excel操作示例
- php study是什么,phpstudy与wamp区别的区别是什么?
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 多线程服务器的适用场合
- Android实现XML解析技术
- unity 手机上获取手指触摸位置_我们到底触摸到了什么?揭秘智能设备触摸屏原理...
- matlab无法显示图片
- tomcat修改端口号
- Java练习题11.2 方法的重载
- strconv,strings的学习(三)
- Shiro学习(22)集成验证码
- 认养农业菜园认租如何助力农业发展?
- MapReduce的执行流程
- 形参的种类及其能否改变实参
- 组播IGMP-原理介绍+报文分析+配置示例
- java留言板_java实现留言板功能实例