O'Reilly logo

Cisco IOS Cookbook, 2nd Edition by Ian Brown, Kevin Dooley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Booting the Router Using a Remote Configuration File


You want to boot the router using an alternate configuration.


The following set of commands allows you to automatically load a configuration file located on a remote TFTP server when the router boots:

Router1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#service config
Router1(config)#boot network tftp Network-auto
Router1(config)#boot host tftp Router8-auto


By default, when the router reloads, it will read the configuration information from a file in its Nonvolatile Random Access Memory (NVRAM). Cisco commonly refers to this file as the startup configuration file. However, you can configure the router to load all or part of its configuration from a remote server via TFTP. This feature does not prevent the router from loading its startup configuration from NVRAM. In fact, the router will load its local startup file first before proceeding to the TFTP server files.

Uses for this feature vary, although most people who implement it do so because their configuration file has grown too large for their NVRAM to handle. It can also be a useful way of keeping an access-list that is shared by a number of routers, centralized and up to date. And we have sometimes used it as a temporary measure when the NVRAM in a router is damaged.

However, we consider this feature to be highly risky and recommend avoiding it in most cases. If the problem is simply one of NVRAM capacity, Recipe 1.4 shows how to compress the startup configuration file to help fit more information into your existing NVRAM. Also, since routers can operate for years without reloading, using this feature to keep your routers up to date seems pointless.

If you choose to implement remote configuration despite these cautions, we should mention a few other items. First, the router will attempt to load a host and a network file. The router will assume that network files are common to all routers, while the host files contain router specific information. When you enable the service config option, the router will attempt to first load a network file and then a host file. If it can’t find these files, the router will generate error messages:

%Error opening tftp:// (Timed out)
%Error opening tftp:// (Timed out)
%Error opening tftp:// (Timed out)
%Error opening tftp:// (Timed out)

Here you can see what happened when we enabled the service config option and reloaded our router, which was called router1. It attempted to load several different files automatically. The first two files have generic network filenames. Then it looks for the host file under two different names. The router attempts to load these configuration files from IP address by default.

Then, when we added the boot commands, the router looks for the specified files from the appropriate TFTP server. Again, notice the order in which the router loaded the files, with the network file first followed by the host file:

Loading Network-auto from (via Ethernet0): !
[OK - 27/4096 bytes]

Loading Router8-auto from (via Ethernet0): !
[OK - 71/4096 bytes]

If you do not configure the router to load specific network or host filenames, it will try to load the default files, shown in the trace above. If these files don’t exist, the router will pause for a significant amount of time while it tries to find them. So when you use this feature, you should always include both a network and a host file to load. If you don’t need a network file, for example, you can put a file on the server that only contains the keyword “end”.

This feature only loads configuration commands into the running configuration. It does not copy them into the startup configuration file.

The show version command tells you whether the router was able to load these files successfully:

Router1#show version
Cisco Internetwork Operating System Software
IOS (tm) 2500 Software (C2500-IO-L), Version 12.2(7a), RELEASE SOFTWARE (fc2)
Copyright (c) 1986-2002 by cisco Systems, Inc.
Compiled Thu 21-Feb-02 02:07 by pwade
Image text-base: 0x0304CF80, data-base: 0x00001000

ROM: System Bootstrap, Version 5.2(8a), RELEASE SOFTWARE
BOOTLDR: 3000 Bootstrap Software (IGS-RXBOOT), Version 10.2(8a), RELEASE SOFTWAR
E (fc1)

Router1 uptime is 4 minutes
System returned to ROM by reload
System image file is "flash:c2500-io-l.122-7a.bin"
Host configuration file is "tftp://"
Network configuration file is "tftp://"

cisco 2500 (68030) processor (revision D) with 16384K/2048K bytes of memory.
Processor board ID 04915359, with hardware revision 00000000
Bridging software.
X.25 software, Version 3.0.0.
2 Ethernet/IEEE 802.3 interface(s)
2 Serial network interface(s)
32K bytes of nonvolatile configuration memory.
16384K bytes of processor board System flash (Read ONLY)

Configuration register is 0x2102

The service config option is disabled by default. However, if the router tries to boot but cannot find its startup configuration file, it will automatically enable this option to attempt to find a configuration file through the network:

00:00:25: AUTOINSTALL: Ethernet0 is assigned
00:00:25: AUTOINSTALL: Obtain siaddr (as config server)
00:00:25: AUTOINSTALL: Obtain default router (opt 3)
%Error opening tftp:// (No such file or directory)
%Error opening tftp:// (No such file or directory)
%Error opening tftp:// (No such file or directory)
%Error opening tftp:// (No such file or directory)
%Error opening tftp:// (No such file or directory)
%Error opening tftp:// (No such file or directory)

Two interesting things happen if you reload a router with an empty configuration file. First, the router enables its autoinstall option and attempts to acquire an IP address via DHCP. In this example, the router obtained a DHCP address of Second, after it obtains a dynamic address, it attempts to load a configuration file via TFTP.

Notice the filenames that the router cycles through in an attempt to load a configuration file. If there happened to be a file with one of these names in the TFTP directory for some other reason, this router will have downloaded it and used its contents to configure itself, which could have caused serious problems.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required