Copy to Running Configuration

In this lesson, we’ll take a closer look at the copy command when you use it to copy something to the running-configuration.

Configuration

Here’s the current running configuration of a router:

R1#show running-config 
Building configuration...

Current configuration : 1072 bytes
!
! Last configuration change at 13:19:49 UTC Tue Jan 31 2017
version 15.1
!
hostname R1
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.2.1 255.255.255.0
 duplex auto
 speed auto
!
end

I removed some of the default settings so that it’s easier to read. We have a hostname (R1) and two interfaces with an IP address.

Copy from running-config

If we want to save this running config, we can copy it to the startup configuration:

R1#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...

[OK]

When we copy the running configuration to whatever destination, it will always overwrite the destination file. Let’s try that:

R1#copy running-config my-config.cfg
Destination filename [my-config.cfg]? 


1072 bytes copied in 1.076 secs (996 bytes/sec)

The first time I save the running configuration as “my-config.cfg” the file does not exist. The second time I do this, it will overwrite the file:

R1#copy running-config my-config.cfg
Destination filename [my-config.cfg]? 
%Warning:There is a file already existing with this name 
Do you want to over write? [confirm]

1072 bytes copied in 0.648 secs (1654 bytes/sec)

Copy to running-config

Copying something to the running configuration works differently. Let’s say I have a file on my flash memory that I want to copy to the running configuration. Here’s the contents of the file:

R1#more flash:backup-config.cfg
!
! Last configuration change at 13:22:49 UTC Tue Jan 31 2017
!
hostname R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!
end

So, what is the difference between this file and the running configuration?

  • There is a new loopback interface with an IP address.
  • FastEthernet 0/0 has a different IP address.
  • There is nothing in it about FastEthernet 0/1.

Let’s see what happens when I copy this file to the running configuration:

R1#copy flash:backup-config.cfg running-config
Destination filename [running-config]? 
1106 bytes copied in 0.268 secs (4127 bytes/sec)

Here’s the end result:

R1#show running-config 
Building configuration...


Current configuration : 1129 bytes
!
! Last configuration change at 13:27:49 UTC Tue Jan 31 2017
!
hostname R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!         
interface FastEthernet0/1
 ip address 192.168.2.1 255.255.255.0
 duplex auto
 speed auto
!
end

If you look at the output above, you can see the running configuration didn’t get replaced but got merged:

  • The IP address on FastEthernet 0/0 was replaced with the IP address from my file.
  • The loopback 0 interface was added.
  • FastEthernet 0/1 remains untouched.

When you copy something to the running configuration, it’s similar to typing commands in configuration mode on the terminal. If it’s not in the running configuration, it will be added. Otherwise it will be replaced.

Here’s a picture ot help you visualize this:

copy running config startup config

In my example, I copied something from the flash memory but it doesn’t matter what source you use. This also applies when you copy the startup-config from the NVRAM into the running configuration. For example, when you copy the startup configuration to the running configuration:

copy running config flash

Erase startup config

So what methods do we have to replace the running configuration? One way is to remove the startup configuration and reload the router:

R1#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: 

 

R1#reload

System configuration has been modified. Save? [yes/no]: no
Proceed with reload? [confirm]

This works, but it’s slow. If you are doing labs then reloading the router over and over again becomes a chore.

Configure Replace

There is a faster method, the configure replace command allows us to replace the running configuration. Here’s how it works:

R1#configure replace flash:backup-config.cfg
This will apply all necessary additions and deletions
to replace the current running configuration with the
contents of the specified configuration file, which is
assumed to be a complete configuration, not a partial
configuration. Enter Y if you are sure you want to proceed. ? [no]: Y

Total number of passes: 1
Rollback Done

Rollback:Acquired Configuration lock.

The command above tells the router to replace the running configuration with the backup-config.cfg file on my flash memory.

Here’s what the running configuration looks like now:

R1#show running-config 
Building configuration...


Current configuration : 1106 bytes
!
! Last configuration change at 13:40:39 UTC Tue Jan 31 2017
version 15.1
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
!
end

This method only takes a few seconds so when doing labs, this is probably a better option.

Conclusion

You have now learned how Cisco IOS behaves when you copy something into the running configuration. You also learned how you can replace the running configuration without reloading the router.

Tags: ,


Forum Replies

  1. Hi Rene,

    Thanks for the ticky article :slight_smile:

    So , Copy from Running Config to any destination file , no issue because its overwrite/ replace with running config easily(write command also do the same things). but the issue on copy to running config , its will merge , right ? So if we want to overwrite the running config then the short way is “configure replace”. Please correct me if i am wrong :slight_smile: . Thanks

    br//zaman

  2. Hello Mohammad.

    Yes, you’ve got it!

    Laz

Ask a question or join the discussion by visiting our Community Forum