In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The function of the script is to save the configuration on the switch instead of manually, and it is a complete operation to log in to the switch, no matter whether the version of the switch is high or low, as long as the command that can be typed within the authority can be realized.
The script is executed as follows: telnet to the designated switch, save the configuration, log in to the server through the switch, enter the username and password, and upload the configuration file of the switch to the FTP server.
Here is the script content (vi tel10.sh):
#! / usr/bin/expect / / expect is used here. If linux does not have it, you need to install / / set date [exec date "+% Y%m%d"] / / assign values to the date variable, and then call / / spawn telnet 192.168.10.10 / / which is a command of expect. Indicates that from telnet to 192.168.1.104//expect "Username:" / / match Username:, in the echo string if it matches, execute the following / / send "admin\ r" / / send the admin string to the switch, that is, enter the user name / / expect "Password:" / / match Password in the echo string: If it matches, execute the following / / send "Admin@huawei\ r" / / to send the Admin@huawei string to the switch. That is, enter the password from tel to the switch / / send "save\ r" / / send the save string to the switch, which is equivalent to executing the save command / / send "Y\ r" / / on the switch, because when the switch is in save, there will be an interactive process to send the string Y It is equivalent to entering Y//send "ftp 192.168.10.1\ r" / / sending the ftp 192.168.1.1 instruction to the switch, and entering the ftp 192.168.1.1 command on the switch, which means logging in to the FTP server / / send "admin\ r" / / sending the string admin That is, enter the user name / / send "Admin@huawei\ r" / / send the string Admin@huawei of the login server. Enter the password / / send "put flash:/vrpcfg.zip / configbck/$date.zip\ r" / / execute the instruction Put, and submit the configuration file to the FTP server / / interact.
Description: 1. Expect must be installed on the Linux server first, otherwise the expect command cannot be executed.
2. Telnet should be installed on the Linux server, otherwise it cannot be telnet. You can also use the ssh login server code here as follows:
Spawn ssh-p 22 admin@192.168.10.10 send "yes\ r" expect "password:" send "Admin@huawei\ r" 3. The instructions sent to the switch vary from switch to switch. Choose the send string as needed, that is, specify the command you want to enter at the switch as needed. Of course, not only backup, such as reload / switchport mode trunk can be done.
The next thing we need to do is create a crontab to automate the task.
[root@permanet ~] # crontab-e00 01 * / home/expect/tel10.exp / / 01:00, daily, monthly, weekly, execute commands under absolute path / /
You can write a rewrite script to create an ip address file, then read the ip in the file, and back it up in turn.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.