ā03-31-2019 03:47 PM
I have a Ubuntu machine which acts as a TFTP Server. I want to configure my cisco ios routers to take configuration from this TFTP server at boot time.
I have a few doubts- Where do I store the configuration file for my cisco router in the TFTP Server? Currently, I have created two temp folders in /var/lib/tftpboot-
automation@automation:/var/lib/tftpboot$ ls -l total 8 drwx------ 2 tftp tftp 4096 Mar 31 15:37 ExrZHRa-incoming drwxr-xr-x 2 root root 4096 Mar 31 15:52 TXJla-outgoing automation@automation:/var/lib/tftpboot$ tree . āāā ExrZHRa-incoming [error opening dir] āāā TXJla-outgoing āāā R1.txt 2 directories, 1 file
As per Cisco's documentation, this is the syntax to get a file from TFTP server-
copy tftp: [[[//location ]/directory ]/filename ] nvram:startup-config Example: Device# copy tftp://server1/dir10/datasource nvram:startup-config
As per my understanding, the location will be IP of my TFTP Server and filename will be the actual config file I want to load. But what should be configured in the directory? I tried with /var/lib/tftpboot/TXJla-outgoing but it didn't work. Error-
ā03-31-2019 04:38 PM
Hi,
If "/var/lib/tftpboot" is the root, the command to copy should be:
copy tftp://198.51.100.2/TXJla-outgoing/R1.txt nvram:startup-config
Thanks
John
ā03-31-2019 05:39 PM
Thanks, that worked! But it just downloads the file. The file has configuration commands to be executed. How to do that?
ā03-31-2019 07:34 PM
Hi,
Depending on the configurations being applied, the file should be copied to the running config.
Thanks
John
ā03-31-2019 08:02 PM
I am trying to use the ZTP approach to configure my router [R2]. My Ubuntu machine is both DHCP and TFTP server.
Ubuntu [DHCP Server]: 16.04.5 LTS Cisco Router [DHCP Client]: 7200, version 15.2(4)S5
This is the python script- ztp.py. ztp.py is stored in /var/lib/tftpboot/
#!/usr/bin/env python3.5.2 import time import cli time.sleep(200) print ("\n\n *** ZTP Day 0 Configuation *** \n\n") fn = open('TXJla-outgoing/R1.txt','r') fn.seek(0) c =fn.readlines() fn.close() cli.configurep([c])
The configuration on dhcpd.conf for host R2 is -
host R2 { hardware ethernet CA:02:3B:E3:00:08; fixed-address 198.51.100.5; option bootfile-name !<opt 67> "/ztp.py"; option tftp-server-name !<opt 150> "198.51.100.2"; }
The configuration is not exected on the Router. Please help resolve.
ā03-31-2019 08:58 PM
Hi,
You cannot get the python script to run in the router's startup or running config. You need to get the python script to log into the router and run commands. The second option is to use the guest shell to run the script.
Thanks
John
ā03-31-2019 09:41 PM
Is there any way to do ZTP using TFTP and DHCP on the Cisco router?
ā03-31-2019 10:58 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide