cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2734
Views
5
Helpful
7
Replies

Issue while copying a Configuration File from a TFTP Server to Cisco IOS Router

ps12
Level 1
Level 1

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-

TFTP.JPG

7 Replies 7

johnd2310
Level 8
Level 8

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

**Please rate posts you find helpful**

Thanks, that worked! But it just downloads the file. The file has configuration commands to be executed. How to do that?  

 

Hi,

Depending on the configurations being applied, the file should be copied to the running config.

 

Thanks

John

**Please rate posts you find helpful**

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.

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

**Please rate posts you find helpful**

Is there any way to do ZTP using TFTP and DHCP on the Cisco router? 

I configured this in dhcpd.conf, but still doesn't work. 
 
host R2 {
  hardware ethernet CA:02:3B:E3:00:08;
  fixed-address 198.51.100.5;
  filename "tftp://198.51.100.2/TXJla-outgoing/R1.txt";
  option tftp-server-name "198.51.100.2";
}
 


 
 

Review Cisco Networking for a $25 gift card