在一行中复制运行配置

网络工程 思科 转变 思科-ios
2021-07-27 21:25:23

我想制作一个脚本来在一行中复制交换机 4506 的运行配置。到目前为止,我看到两个选项:

复制运行 tftp:

sw#copy run tftp://10.0.0.1/cfg.cfg
Address or name of remote host [10.0.0.1]? 
Destination filename [cfg.cfg]? 

缺点:需要确认,按回车。

信息:我已经定义了ip tftp source-interface Vlan10与管理 vlan 的连接。

或者

显示运行配置 | 重定向 tftp://10.0.0.1/run-R1.cfg

sw#show running-config | redirect tftp://10.0.0.1/run-R1.cfg
.....
%Error opening tftp://10.0.0.1/run-R1.cfg (Timed out)
sw#sh ip route 10.0.0.1 
% Subnet not in table

缺点:重定向的 IP 源是私有 IP 172.16.0.2,因为这是一个传输子网。所以没有与传出接口 IP 的连接,但与管理子网的连接。正如你在下面看到的。

sw#ping 10.0.0.1 source vlan 10    
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
Packet sent with a source address of 172.16.0.2 
.....
Success rate is 0 percent (0/5)
sw#ping 10.0.0.1 source vlan 11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
Packet sent with a source address of <Public_IP> 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/8 ms
sw#

ip tftp source-interface Vlan10 没有帮助 redirect

问题:
- 是否有可能没有使用“copy run tftp:”进行确认复制?
- 如何定义交换机上的所有数据包都应使用已定义的 IP?

4个回答

尝试将文件提示行为转为安静。

6506(config)#file prompt quiet
6506(config)#end
6506#copy run tftp://192.168.1.1/file.txt
.....

copy 命令(至少对于 Cisco 设备)允许您在一行中指定用户名和密码。像这样的东西:

copy running-config ftp://put_user_name_here:put_password_here@put_machie_name_or_ip_here//home/users/some_location/ut-running-config.txt

您也应该能够使用 scp 或 tftp 代替 ftp。

您可以使用 FTP 执行此操作。

首先你需要设置FTP用户名和密码:

ip ftp username xxx
ip ftp password xxx

然后让你的脚本做到这一点:

show run | redirect ftp://1.1.1.1

然后IOS会使用之前设置的本地用户名和密码

在路由器上启用 SCP 服务器并从另一端编写备份脚本可能更容易。与其尝试从路由器中推送它,为什么不从备份服务器中提取它呢?通过这种方式,您将拥有更大的脚本编写灵活性。