Courseiva
DiagnosticsPrivileged EXEC

clear counters

Reset interface statistics to measure error rates from a known baseline rather than cumulative since last reboot.

Definition: clear counters is a Cisco IOS privileged exec command. Resets all interface packet and error counters to zero without affecting the interface operational state, allowing a clean baseline for traffic monitoring or error rate measurement.

Overview

The 'clear counters' command in Privileged EXEC mode resets all interface statistics to zero. This is a fundamental tool for network engineers who need to baseline performance, isolate transient issues, or verify that recent configuration changes have taken effect. The command clears counters such as input/output packets, errors, CRC failures, collisions, and interface resets.

It does not affect the running configuration or interface state; it only resets the statistical counters maintained in RAM. This is critical because stale counters can mislead troubleshooting—for example, a high error count from a past broadcast storm may obscure a current duplex mismatch. By clearing counters, you establish a clean starting point for monitoring.

The command is typically used before a targeted test (e.g., pinging across a link) or after applying a fix (e.g., changing cable or speed/duplex settings). It is also common to clear counters on all interfaces at the start of a maintenance window. Alternatives include 'clear counters [interface]' for a single interface, or 'clear interface' which resets counters and also reinitializes the interface hardware (causing a brief outage).

The 'clear counters' command is less disruptive. In IOS, the output of 'show interfaces' is buffered; clearing counters does not affect the buffer contents. The command requires privilege level 15 (enable mode).

It does not appear in the running configuration. One important behavior: counters for some sub-interfaces or VLAN interfaces may not be cleared if the parent interface is not explicitly specified. Also, on some platforms, counters for hardware-based features like QoS or ACL hits may not be cleared by this command.

Understanding when to clear counters is part of a disciplined troubleshooting methodology: first gather baseline data, then clear counters, then reproduce the issue, then compare new counters to baseline. This command is a staple in the CCNA and CCNP curriculum because it teaches the importance of accurate data collection.

Syntax·Privileged EXEC
clear counters [interface-id]

When to Use This Command

  • Establish a clean baseline before monitoring for CRC errors during a cabling test
  • Reset counters after fixing a duplex mismatch to confirm errors stop accumulating
  • Clear high input/output error counts that are masking current error rate
  • Reset packet counters before capturing a QoS measurement window

Parameters

ParameterSyntaxDescription
interface-type interface-numbere.g., GigabitEthernet0/1 or Serial0/0/0Specifies a particular interface to clear counters. If omitted, counters for all interfaces are cleared. Common mistake: using the wrong interface name or number, which results in an 'Invalid input detected' error. Also, for sub-interfaces, you must specify the full interface name (e.g., GigabitEthernet0/1.100).

Command Examples

Clear counters on a specific interface

Router# clear counters GigabitEthernet0/0
Clear "show interface" counters on this interface [confirm]
Router#
%CLEAR-5-COUNTERS: Clear counter on interface GigabitEthernet0/0 by console

Clear all interface counters

Router# clear counters
Clear "show interface" counters on all interfaces [confirm]
Router#

Understanding the Output

IOS prompts for confirmation (press Enter to confirm). The syslog message records who cleared the counters (console, vty, username) for auditing. After clearing, show interfaces shows all counters at 0.

The 'Last clearing of show interface counters' timestamp in show interfaces output updates to reflect when clear counters was last run.

Configuration Scenarios

Clearing counters on a single interface after troubleshooting a high error rate

A network engineer notices a high number of CRC errors on interface GigabitEthernet0/1 of a router. After replacing the cable, the engineer wants to verify that errors stop accumulating.

Topology

R1(Gi0/1)---192.168.1.0/30---(Gi0/0)R2

Steps

  1. 1.Step 1: Enter privileged EXEC mode: enable
  2. 2.Step 2: Clear counters on the specific interface: clear counters GigabitEthernet0/1
  3. 3.Step 3: Confirm the action when prompted: yes
  4. 4.Step 4: Verify counters are reset: show interfaces GigabitEthernet0/1 | include errors
Configuration
! No configuration change; this is an exec command
Router> enable
Router# clear counters GigabitEthernet0/1
Clear "show interface" counters on this interface [confirm] yes
Router#

Verify: Use 'show interfaces GigabitEthernet0/1' and check that input errors, CRC, frame errors, etc., show 0. Expected output snippet: '0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored'.

Watch out: If you clear counters on an interface that is in a 'down' state, the counters will still reset, but the interface will not automatically come up. Also, clearing counters does not clear the 'reliability' or 'load' metrics; those are calculated over a 5-minute moving average.

Clearing all interface counters before a performance test

Before running a throughput test between two branch routers, the engineer wants to reset all interface counters to get accurate measurements of packet loss and errors during the test.

Topology

R1(Gi0/0)---10.10.10.0/30---(Gi0/0)R2 R1(Gi0/1)---10.10.20.0/30---(Gi0/1)R2

Steps

  1. 1.Step 1: Enter privileged EXEC mode: enable
  2. 2.Step 2: Clear counters on all interfaces: clear counters
  3. 3.Step 3: Confirm the action when prompted: yes
  4. 4.Step 4: Start the performance test (e.g., iperf or extended ping)
  5. 5.Step 5: After test, check counters: show interfaces | include errors|packets
Configuration
! No configuration change
Router> enable
Router# clear counters
Clear "show interface" counters on all interfaces [confirm] yes
Router#

Verify: Use 'show interfaces' to verify all counters are zero before the test. After the test, compare counters to identify any errors. Expected: input/output packets increase, errors remain zero if link is clean.

Watch out: Clearing all counters is disruptive if you are monitoring long-term trends; it erases historical data. Also, on some platforms, counters for management interfaces (e.g., GigabitEthernet0/0) may not be cleared if they are in a different VRF.

Troubleshooting with This Command

The 'clear counters' command is indispensable in a structured troubleshooting workflow. Healthy output after clearing counters shows all counters at zero. As traffic flows, you expect to see increasing packet counts, but error counters should remain zero or very low (e.g., less than 0.1% of total packets).

Problem indicators include rapidly incrementing error counters such as CRC, frame, runts, giants, or collisions. For example, a high CRC error count often points to a physical layer issue like faulty cabling, bad SFP, or electromagnetic interference. Input errors (including CRC, frame, overrun, ignored) suggest issues on the receive side.

Output errors (including collisions, late collisions, underruns) indicate problems on the transmit side. A step-by-step diagnostic flow: 1) Before any troubleshooting, record current counters. 2) Clear counters to reset baseline. 3) Reproduce the issue (e.g., generate traffic). 4) Check counters again. If errors reappear, focus on the specific error type.

For CRC errors, check cable, duplex mismatch, or speed mismatch. For collisions, check for half-duplex or excessive network diameter. For input errors, check for buffer overflow or hardware failure.

Correlate with 'show interfaces' for interface status and 'show controllers' for detailed hardware statistics. Also use 'debug interface' cautiously to see real-time events. The 'clear counters' command helps isolate whether errors are ongoing or historical.

If after clearing, errors do not increase, the issue may have been transient. If they increase immediately, the problem is active. This command is often used in conjunction with 'show interfaces' and 'show logging' to correlate errors with events.

Remember that clearing counters does not affect interface state; if the interface is down, counters will not change. Always verify interface status first.

CCNA Exam Tips

1.

CCNA exam: clear counters resets Layer 1/2 statistics (input errors, CRC, output drops, collisions) but does NOT reset routing protocol counters or QoS statistics

2.

Use show interfaces to see 'Last clearing of counters' timestamp

3.

Does not affect the routing table or adjacencies

Common Mistakes

Thinking clear counters will fix the underlying issue — it only resets counters for measurement purposes

Forgetting IOS prompts for confirmation — must press Enter

Using clear counters when show interfaces already shows the timestamp of last clearing — may reset a useful history

clear counters vs show interfaces

Both 'clear counters' and 'show interfaces' are used for interface diagnostics in Cisco IOS, but they serve opposite purposes: one resets statistics and the other displays them. They are often paired when engineers need to establish a fresh baseline (clear counters) and then verify new statistics (show interfaces).

Aspectclear countersshow interfaces
FunctionResets all interface counters to zeroDisplays current interface counters and status
Effect on CountersZeros out input/output packets, errors, and other statisticsRead-only; does not modify any counters
PersistenceImmediate runtime change; not saved to startup-configShows runtime values; no configuration change
ScopeCan target a single interface or all interfacesCan target a single interface or all interfaces
Typical Use CaseEstablish a clean baseline for monitoring or error-rate measurementTroubleshoot connectivity issues or inspect current performance

Use clear counters when you need to reset interface statistics to zero to establish a clean baseline for monitoring or error tracking without affecting interface operation.

Use show interfaces when you need to inspect current interface statistics, line protocol status, or error counters to diagnose connectivity issues or performance.

Platform Notes

In IOS-XE (e.g., Catalyst 9000 switches), the 'clear counters' command works identically to classic IOS. However, on some IOS-XE platforms, counters for port-channel interfaces may require clearing on the individual member ports. The syntax is the same: 'clear counters [interface]'.

On NX-OS (e.g., Nexus switches), the equivalent command is 'clear counters [interface]' as well, but note that NX-OS uses a different output format for 'show interface'. Also, NX-OS has a 'clear counters interface ethernet x/y' command. On ASA firewalls, the command is 'clear interface [name] counters' or 'clear counters all'.

The ASA also supports 'clear service-policy counters' for QoS. In IOS-XR, the command is 'clear counters [interface]' but the output is XML-based; the command is available in XR. For IOS versions, there is no significant difference between 12.x, 15.x, and 16.x for this command.

However, in newer IOS versions, the prompt may ask for confirmation by default, while older versions might not. Always confirm the action. On some platforms, clearing counters on a VLAN interface may not clear the parent physical interface counters.

Also, on switches, clearing counters on a switchport may not clear the port's MAC address table counters. Always check the specific platform documentation.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions