Configuring the Router via TFTP

Problem

You want to load configuration commands via TFTP.

Solution

You can use the copy tftp: command to configure the router via the Trivial File Transfer Protocol (TFTP):

Router1#copy tftp://172.25.1.1/NEWCONFIG running-config
Destination filename [running-config]? 
Accessing tftp://172.25.1.1/NEWCONFIG...
Loading NEWCONFIG from 172.25.1.1 (via FastEthernet0/0.1): !
[OK - 24 bytes]

24 bytes copied in 0.192 secs (125 bytes/sec)
Router1#

IOS versions before 12.0 used the command configure network. This command is still available in more recent versions, but it is now deprecated and may not continue to be available in the future.

 

Discussion

Generally, most people configure their routers by using Telnet and the configure terminal command. For large configuration changes, people tend to resort to cutting and pasting a large set of commands. While this method works, it is inefficient and slow, particularly if you have to configure large numbers of routers. When you use TFTP to download a large set of configuration commands, the router doesn't need to echo each character to your screen, which reduces the overhead and increases the speed.

In our example, we configured the router by making it download the file called NEWCONFIG from the server at 172.25.1.1 by using the Trivial File Transfer Protocol (TFTP). The router will copy the entire file via TFTP before entering the commands into the running configuration. This is extremely useful because sometimes some commands in the middle of a configuration could disrupt your access to the router, but the rest of the commands might fix the problem. If you tried to enter them manually using TELNET and configure terminal, you would simply lock yourself out of the router and not be able to continue. A typical example of this problem happens when you replace an active access-list. When you enter the first line, the router puts an implicit deny all at the end, which could break your session. However, entering commands by using TFTP avoids this problem.

We mention in passing that the last line of any configuration file that you copy into the router like this should be the end command so the router knows that it has reached the end of the file. If you don't do this, the router still will accept all of the commands normally, but will put the following error into its logs:

Jan 19 11:26:38: %PARSER-4-BADCFG: Unexpected end of configuration file.

If you have the end command in your configuration file, then seeing this message will tell you that the router didn't get all of the configuration commands. But if you don't terminate the file properly, it's impossible to tell if the transfer was successful.

Instead of TFTP, you can use the FTP protocol to download configuration files. FTP has a number of advantages over TFTP in terms of reliability and security. Recipe 1.14 shows how to load configuration commands by using FTP instead of TFTP.

See Also

Recipe 1.14

Router Configuration and File Management

Router Management

User Access and Privilege Levels

TACACS+

IP Routing

RIP

EIGRP

OSPF

BGP

Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time

DLSw

Router Interfaces and Media

Simple Network Management Protocol

Logging

Access-Lists

DHCP

NAT

First Hop Redundancy Protocols

IP Multicast

IP Mobility

IPv6

MPLS

Security

Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications

Index



Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net