Category: network management
Logging to flash disk
- The directory argument specifies where you want the files to be stored (for example, flash:/logging).
- The filesystem-size specifies the maximum disk space the logging files can consume (once you exceed the limit, the oldest file is deleted)
- The logging-file-size parameter specifies the maximum size of each file (once the file grows too large, a new file is created).
Note: You can store the log files on the router's flash memory if it appears as a disk file system (check with the show file systems command). Wouldn't it be great if this feature would also work on USB drives ...
Warm reload does not change the config register
Sample configuration: periodic upload of router configuration
Pete Vickers sent me a very interesting configuration sample:
To get an IOS device to upload it’s configuration periodically to an external FTP server:
ip ftp source-interface loopback 0
ip ftp username ftp_username
ip ftp password ftp_password
file prompt quiet
!
kron policy-list backup
cli copy running-config ftp://10.20.30.40
!
kron occurrence daily-backup at 0:30 recurring
policy-list backup
The beauty of this example is that you can use it on platforms that don't support Embedded Event Manager (which has a very similar cron functionality) as the kron commands were introduced in 12.2T and 12.3 IOS releases.
Note: You have to use the file prompt quiet configuration command as the commands executed by kron cannot supply any user input
Display per-process memory usage
router#show processes memory sortedUsually the top entry is the *Init* process, which allocates all shared buffers, but routing processes could also exhibit significant memory utilization in large networks.
Total: 13734272, Used: 6372068, Free: 7362204
PID TTY Allocated Freed Holding Getbufs Retbufs Process
0 0 135340 1864 4734916 0 0 *Init*
55 0 242388 188 249076 0 0 URL filter proc
69 0 317996 143308 182184 0 0 IPSEC key engine
62 2 277048 124752 165172 0 0 Virtual Exec
68 0 762828 657056 109896 0 0 Crypto IKMP
80 0 74556 1100 73772 0 0 CEF process
91 0 25704 188 28776 0 0 NTP
67 0 3116 51368 27904 0 0 Crypto ACL
83 0 184 0 25060 0 0 traffic_shape
30 0 89900 0 24700 0 0 IP Input
46 0 32248 1776 23596 0 0 DHCPD Receive
35 0 10236 540 16572 0 0 PPPOE discovery
48 0 95344 51488 14724 0 0 HTTP CORE
MPLS Ping and Traceroute
One of the hardest troubleshooting problems within an MPLS VPN network has always been finding a broken LSP. While you could (in theory) use the IP ping or traceroute (assuming all hops support ICMP extensions for MPLS), the results are not always reliable… and interpreting them is not so easy. For example, after I've disabled LDP on an interface with the no mpls ip configuration command, the routers in the LSP path still reported outgoing MPLS labels in ICMP replies for a few seconds (until the LDP holddown timer expired on both ends of the link).
As a side note, would you deduce from the printout that the break in the LSP path happened on the router with the IP address 192.168.201.1?
Fix the IOS quiet mode for the IOS HTTP(S) server
If you want to block HTTP requests during the quiet mode, you can use EEM applets to change the HTTP server configuration when the quiet mode is started and completed.
First you need to configure a standard numbered IP access list that will be used to block HTTP requests during the quiet mode (the ip http access-class command accepts only numbered ACLs), for example:
access-list 95 deny any logThen you define two EEM applets: one that triggers when the router enters the quiet mode (matching the SEC_LOGIN-1-QUIET_MODE_ON syslog message) and another that runs when the quiet mode is finished (triggered with the SEC_LOGIN-5-QUIET_MODE_OFF). Both applets modify the router configuration, changing the access-list used in ip http access-class configuration command.
event manager applet EnterQuietMode
event syslog occurs 1 pattern "SEC_LOGIN-1-QUIET_MODE_ON" period 1
action 1.0 cli command "configure terminal"
action 1.1 cli command "ip http access-class 95"
action 2.0 syslog msg "Entered Quiet mode on HTTP server"
!
event manager applet ExitQuietMode
event syslog occurs 1 pattern "SEC_LOGIN-5-QUIET_MODE_OFF" period 1
action 1.0 cli command "configure terminal"
action 1.1 cli command "ip http access-class 70"
action 2.0 syslog msg "Exiting Quiet mode on HTTP server"
Warm upgrade
Apart from the downtime reduction, the warm upgrade (requested with the reload warm file url command) has a number of other benefits:
- The new image does not have to be stored in flash
- You don't have to change the boot image with the boot system command
- If the new image crashes, the router will revert to the original IOS image stored in flash
Background Continuous Ping from a Router
ip sla 100To start the ping, use the ip sla schedule 100 life forever start-time now configuration command, to stop it, no ip sla schedule 100 command. When using IP SLA ping, you can trigger Embedded Event Manager applets to report ping failure (similar to the technique described in this post) or read the ping results from SLA MIB with SNMP.
icmp-echo 172.16.1.2
timeout 500
frequency 3
Note: In IOS release 12.3(14)T, the ip sla command replaced the rtr command. To use this technique in IOS release 12.3 or lower, use the rtr configuration command.
Save IOS printouts in a file
The show output can be redirected to a local filename (in flash, on usb token or even in NVRAM) or sent to a remote server (currently only FTP and TFTP servers are supported). For example, the show ip interface brief | redirect ftp://student:[email protected]/ifstatus command will store the current interface status to an FTP server.
Note: the append (or tee /append) operation only works on destinations that support the file append operation: class-C flash file systems, local disks, USB tokens and NVRAM.
Display top CPU processes on the router
Warm reload
The theory behind warm reload is simple: the router saves initial data (as stored in IOS image) in a separate memory region and reuses saved data together with IOS code already residing in RAM to restart IOS. Of course, the IOS code (depending on platform's memory management capabilities) or saved data could get corrupted, therefore the warm reload cannot be used continuously (and the router falls back to traditional reload if the router crashes before a specified time interval).
Warm reload is configured with the warm-reboot count number uptime minutes configuration commands. After it has been configured, a router reload (or power-up) is needed to initialize the saved data region. When the warm reboot is operational (as verified with the show warm-reboot command), you can use reload warm command to start it.
Reload a Router When Ping Fails
One of my readers has asked an interesting question: can you reload a router when pinging a specific IP address from it fails? While there are other ways of dealing with stuck interfaces or routing processes, sometimes such a drastic measure is the only workaround, so here's how you do it:
Display Configuration of a Single Interface
Displaying configuration of a single interface can be a time-consuming task if your router has extremely long configuration (for example, high-end device with hundreds of interfaces, route-maps, access-lists etc.). In this case, the interface keyword of the show running-config command becomes extremely useful.
Save the approximated date-and-time in NVRAM
This requirement is not a problem for most router models, as they have battery-backed hardware clock that continues running even when a router is reloaded or powered down. The low-end models, though, have a problem, as they always start with the default date/time after the reload. These devices have to get their time from an NTP/SNTP server before being able to establish the IPSec session. If the (S)NTP server is only accessible across the VPN, you have a nice chicken-and-egg problem.
The versatile more command
Note: IOS documentation claims that the show running command is obsolete and that you should use more system:running-config. This is not true, as the show running command has a number of interesting options that are not implemented with the more command.