当前位置:网站首页 > 网络设备调试 正文 网络设备调试

linux备份华为交换机,利用expect脚本实现备份华为交换机配置

frank 2025-09-01 22:15:55 网络设备调试 1 ℃ 0 评论

在平常工作中需要定期备份交换机配置,如果一个个手动备份,工作量十分巨大,那有没有什么好的工具来减轻我们备份的工作量呢?经过查找资料,发现可以利用expect脚本来实现,expect可以与shell相互配合,以使Linux shell能够支持交互。可以让我们登录到服务器及网络设备上执行例行性工作及批处理操作等。

整体思路:我们利用脚本登录交换机执行命令,以便将配置文件保存到tftp服务器上,因此需要expect环境的准备以及tftp服务器的准备。

一、 expect环境的准备

操作系统:CentOS 6.3 最小化安装

[[email protected] /]# yum -y install expect #安装expect+tcl环境

linux备份华为交换机,利用expect脚本实现备份华为交换机配置

[[email protected] /]# yum -y install openssh-clients #安装openssh

#我这里的环境登录交换机是采用ssh登录所以需要安装

二、 tftp服务器的准备

更改tftp配置文件

[[email protected] /]# yum -y install tftp tftp-server #安装tftp软件,以便存储配置文件

[[email protected] /]#mkdir /opt/tftp #建立tftp目录

[[email protected] /]#chmod 777 –R /opt

[[email protected] /]# vi /etc/xinetd.d/tftp #编辑配置文件

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /opt/tftp -c

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

#指定tftp目录并启用

[[email protected] /]# /etc/init.d/xinetd restart #重启xinetd服务

关闭iptables

[[email protected] /]#servive iptables stop

关闭selinux

[[email protected] /]# vi /etc/selinux/config

SELINUX=disable

版权说明:如非注明,本站文章均为 扬州驻场服务-网络设备调试-监控维修-南京泽同信息科技有限公司 原创,转载请注明出处和附带本文链接

请在这里放置你的在线分享代码
«    2025年9月    »
1234567
891011121314
15161718192021
22232425262728
2930
搜索
最新留言
    文章归档
    网站收藏
    友情链接