Loading Configuration Files

Loading and saving configuration files is much simpler than loading a kernel image. This section summarizes the commands that load and save the configuration.

2.6.1. Loading the running-config

Once loaded, the running configuration is used by the router immediately. Use these commands to load it using either TFTP or RCP:

Router#copy tftp running-config (for TFTP) Router#copy rcp running-config (for RCP) Router#copy scp://user@ip:. running-config (for SCP)

 

2.6.2. Loading the startup-config

The startup configuration is not used until the router is rebooted. Loading the startup configuration can be dangerous because the router doesn't parse the configuration file and won't give you any warning if the file has errors. The configuration is not parsed until the router is rebootedand if the configuration is incorrect, the router may not boot properly. Therefore, use the following commands with care:

Router#copy tftp startup-config (for TFTP) Router#copy rcp startup-config (for RCP) Router#copy scp://user@ip:. startup-config (for SCP)

 

2.6.3. Saving running-config to startup-config

The following command is the most important command of all, because if you don't save your running configuration, all your configuration changes will be lost during the next reboot of the device. Once you are satisfied that your current router configuration is correct, copy your configuration to the startup configuration with this command:

Router#copy running-config startup-config

 

2.6.4. Viewing a Configuration

The following commands display the startup or the running configuration:

Router#show startup-config Router#show running-config

 

2.6.4.1. Options for the show config command

For the two show commands listed above, we can add some optional modifiers to change the output format. One option is to add line numbers to the output. You can do this with the linenum option:

Router1#show running-config linenum Building configuration... Current configuration : 868 bytes 1 : ! 2 : version 12.3 3 : service timestamps debug datetime msec 4 : service timestamps log datetime msec 5 : service password-encryption 6 : service udp-small-servers 7 : service tcp-small-servers 8 : ! 9 : hostname Router

With the interface option, you can tell the router to just show you the configuration of a certain interface:

Router#show running-config interface ethernet 0 Building configuration... Current configuration : 109 bytes ! interface Ethernet0 description local lan ip address 192.168.0.100 255.255.255.0 no ip route-cache end

If you want, you can have the output of the show command go directly to a URL for storage. In this example, we direct the output of the show command to be stored on a TFTP server.

Router# show running-config | redirect tftp://192.168.0.4/config1.txt

Finally, the output of the show command can be massaged with a regular expression. In this example, we are going to exclude any lines that have the "!" symbol. What we will see is a configuration without any comments or separators:

Router#show running-config | exclude ! Building configuration... Current configuration : 868 bytes version 12.3 service timestamps debug datetime msec service timestamps log datetime msec service password-encryption service udp-small-servers service tcp-small-servers hostname Router boot-start-marker boot-end-marker enable password 7 1445475BBE

 

2.6.4.2. Stopping the More prompt

When you show running or starting configurations, you'll get a prompt when the router thinks it has filled your terminal screen. This prompt is More. And it means that the router wants you to hit a key before it displays more information. While this feature is extremely useful, sometimes you don't want this prompt to appear. For example, if you are writing a script to capture the configuration output, the More prompt can be intrusive.

This feature is easy to disable. With the terminal length command, you can set the number of lines that your terminal can display. This number is what the router uses to calculate when to prompt. If you set this value to 0, the prompting is disabled for the entire session.

Router#terminal length 0

 

2.6.5. Erasing a Stored Configuration

The following command deletes the startup configuration. Obviously, this is not a very frequently used command. For example, you might delete the startup configuration if you were retiring your router.

Router#erase startup-config

 

2.6.6. Saving a Configuration to a Network Server

The following commands save the running configuration or the startup configuration to a server on the network, using TFTP, RCP, or SCP:

Router#copy running-config tftp (for TFTP) Router#copy running-config rcp (for RCP) Router#copy running-config scp://user@ip (for SCP) Router#copy startup-config tftp (for TFTP) Router#copy startup-config rcp (for RCP) Router#copy startup-config scp://user@ip (for SCP)

Категории