Display and Save Configuration to Flash

The current configuration of the device can be displayed in the form of a virtual file containing the full set of commands necessary to create an identical configuration. A few exceptions exist because certain items are not displayed, such as private SSH keys. This file is called running-config and is volatile by nature; it does not survive across reboots. It is therefore necessary to save the file to flash storage under the name startup-config, as this file is read and executed upon every boot and is therefore responsible for restoring the running configuration of the system to the state it had when the save took place. The command show running-config will display the configuration settings as seen below. For brevity, some details were edited out. In addition, the set of interfaces is dependent on hardware capabilities.

my-device# show running-config
Building configuration...
hostname my-device
username admin privilege 15 password encrypted
3ad61dc090116a16a7cc9861485e60e6407c5a328015b1985b585ab353c37a4441e034172401
528229795a5c9529dfbc04c86e01
!
vlan 1,42
!
spanning-tree mst name 00-01-c1-00-ad-80 revision 0
! [...]
!
interface GigabitEthernet 1/1
!
interface GigabitEthernet 1/2
!
! [...]
!
interface 2.5GigabitEthernet 1/1
!
interface 2.5GigabitEthernet 1/2
!
interface vlan 1
ip address dhcp fallback 172.16.1.2 255.255.0.0
!
line console 0
!
line vty 0
!
! [...]
!
end
my-device#

Lines that begin with ‘!’ are comments. The file begins with the hostname command and the password for the admin user, followed by VLANs 1 and 42 and other items, such as Spanning Tree Protocol (STP). A list of all port interfaces on the device, ordered by switch ID, type, and port number comes next. All port interfaces are at default settings, so nothing is displayed for them. As a general rule, only nondefault configuration is displayed, otherwise the output would be huge and readability would suffer. There are a few exceptions that will be discussed later. Following the physical interfaces are VLAN interfaces 1 and 42. Only the former has an IP address assigned. Finally, the line section is shown. It specifies characteristics for the serial console (line console 0) or network ICLI management connections (line vty x). The configuration as displayed above is also what is saved to startup-config.

my-device# copy running-config startup-config
Building configuration...
% Saving 1326 bytes to flash:startup-config
my-device# dir
Directory of flash:
r- 1970-01-01 00:00:00 648 default-config
rw 1970-01-03 18:21:28 1326 startup-config
2 files, 1974 bytes total.
my-device# more flash:startup-config
hostname my-device
username admin privilege 15 password encrypted
3ad61dc090116a16a7cc9861485e60e6407c5a328015b1985b585ab353c37a4441e034172401
528229795a5c9529dfbc04c86e01
!
vlan 1,42
[...]

The dir command lists the files in the flash file system while more outputs the contents of the designated file. The skills exercised in this section form the basis for all day-to-day work with the ICLI on the device: logging in, displaying information with the show command, working with configuration files (show running-config, copy, dir, more), working with the actual configuration (configure terminal, exit), and sub-modes (interface ...). The configuration proceeds in the same manner as setting the hostname: Enter configuration mode, input and execute configuration commands, leave configuration mode. The following commands instruct the device to use DHCP to obtain an IP address, or, if DHCP fails, to use a static fallback address. Inclusion of a fallback IP is optional and may be omitted.

Last updated