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]?<enter>
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#
Tip
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.
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.
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.