How to use expect script to implement backup Huawei Switch configuration (i)

Source: Internet
Author: User
Tags implement syslog iptables backup

In the ordinary work need to back up the switch configuration regularly, if a manual backup, the workload is very large, there is no good tool to reduce the workload of our backup? After searching for data, it is found that expect scripts can be used to implement, expect can interact with the shell to enable the Linux shell to support interaction. Allows us to log on to the server and network devices to perform routine work and batch processing operations.

The whole idea: we use scripts to log in to the switch to execute commands to save the configuration file to the TFTP server, so we need to expect the environment and prepare the TFTP server.

I. Preparation of the Expect environment

Operating system: Centos 6.3 Minimal Installation

[Root@game-syslog-o/]# yum-y Install expect #安装expect +TCL environment

[Root@game-syslog-o/]# yum-y Install openssh-clients #安装openssh

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

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Network/jhjs/

Ii. preparation of the TFTP server

Change TFTP configuration file

[Root@game-syslog-o/]# yum-y Install tftp tftp-server #安装tftp软件 to store configuration files

[Root@game-syslog-o/] #mkdir/opt/tftp #建立tftp目录

[Root@game-syslog-o/] #chmod 777–r/opt

[Root@game-syslog-o/]# 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目录并启用

[Root@game-syslog-o/]#/etc/init.d/xinetd Restart #重启xinetd服务

Close Iptables

[Root@game-syslog-o/] #servive iptables stop

Close SELinux

[Root@game-syslog-o/]# Vi/etc/selinux/config

Selinux=disable

#重启生效

All the preparations have been done, so let's take a look at the script.

To be Continued ~

This article from the "Wang 11" blog, please be sure to retain this source http://wangshiyi.blog.51cto.com/703685/1122154

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.