cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1229
Views
0
Helpful
5
Replies

Save_config to TFTP in netmiko

I want to save the startup-config to TFTP server with the class .save_config in netmiko but when i call it the server not respone. Of course I try by CLI on router : copy startup-config tftp://10.64.0.146 it works. The code is SSH to  Router OK

This is output:

 

R1941#
10.64.0.146
Trying 10.64.0.146 ...
% Connection refused by remote host

 

This is my code:

 

net_connect = ConnectHandler(**router)
        net_connect.enable()
        promt = net_connect.find_prompt()
        print(promt)
        tftp_server = '10.64.0.146'
        name_cfg = str('Router_' + date_backup + '_config')
        output = net_connect.save_config (tftp_server, name_cfg + '.txt')
        net_connect.disconnect()

 

Thank you!

5 Replies 5

Can you check on the TFTP side and see what incoming IP is seen and port?

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

I try by the CLI the command R1941#copy startup-config tftp://10.64.0.146/, and it work, i can backup startup-config

Hi

 Where in your code you are saying this is a tftp call?

 On the command line when you add tftp:// the IOS knows that this tcp port 69. But, looking the code, I did not see any reference to the protocol only the IP address.

M02@rt37
VIP
VIP

Hello @kevintrankevin18241;

The problem lies in the incorrect usage of the "save_config" method in Netmiko. The "save_config" method is used to save the running configuration of the device to the startup configuration, not to backup the configuration to a TFTP server.

Try with this command "send_command()"

net_connect = ConnectHandler(**router)
net_connect.enable()

tftp_server = '10.64.0.146'
name_cfg = 'Router_' + date_backup + '_config'

command = f'copy startup-config tftp://{tftp_server}/{name_cfg}.txt'
output = net_connect.send_command(command)

net_connect.disconnect()

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

Agree with you, I try this class with default information and the code run with the "write mem" command. I try another way by the code:

 

net_connect.send_command_timing(config_commands)

 

it work! Thankyou!