clear ip route *
Clears all entries from the IP routing table, forcing the router to rebuild the routing table from active routing protocols and directly connected networks.
Definition: clear ip route * is a Cisco IOS privileged exec command. Clears all entries from the IP routing table, forcing the router to rebuild the routing table from active routing protocols and directly connected networks.
Overview
The `clear ip route *` command is a powerful and disruptive tool used in Cisco IOS to flush the entire IP routing table from a router's memory. This command is typically executed in privileged EXEC mode (enable mode) and forces the router to rebuild its routing table from scratch. The routing table is a critical data structure that stores the best paths to destination networks, learned via directly connected interfaces, static routes, or dynamic routing protocols such as OSPF, EIGRP, and BGP. When you issue `clear ip route *`, all routes are immediately removed, and the router must re-learn them through routing protocol updates or re-evaluate static routes. This command is not saved to the running configuration; it is a runtime operation that affects the current state of the router.
Understanding when to use `clear ip route *` versus more targeted alternatives is essential for network engineers. The primary use case is during troubleshooting when the routing table becomes corrupted, inconsistent, or contains stale entries due to flapping links, misconfigured routing protocols, or memory corruption. For example, if OSPF neighbors are fully adjacent but routes are missing or incorrect, clearing the routing table can force a fresh convergence. However, this command is a sledgehammer; it causes a temporary loss of reachability to all networks until the routing table is repopulated. In production networks, this can cause significant disruption, so it should be used with caution, often during maintenance windows or in lab environments. More surgical alternatives include `clear ip route {network} {mask}` to remove a specific route, or protocol-specific clears like `clear ip ospf process` or `clear ip eigrp neighbors` to reset routing protocol adjacencies without wiping the entire table.
The command fits into a broader troubleshooting workflow. Typically, an engineer would first verify the routing table with `show ip route`, check routing protocol status with `show ip ospf neighbor` or `show ip eigrp topology`, and examine interface states. If inconsistencies are found—such as routes pointing to next-hop addresses that are unreachable, or missing routes that should be present—the engineer might decide to clear the routing table. After issuing `clear ip route *`, the engineer monitors the router as it re-establishes adjacencies and re-learns routes. Verification commands like `show ip route` and `show ip protocols` are used to confirm that the table is correctly rebuilt. It is important to note that the command does not affect the running configuration; static routes and routing protocol configurations remain intact. However, any dynamic routes that were previously learned but are no longer advertised will not reappear.
Cisco IOS behavior includes that the command is executed immediately, and the output is buffered; the router may take several seconds to minutes to fully converge depending on the network size and routing protocol timers. The command requires privilege level 15 (enable mode). There is no undo command; once cleared, the routes are gone. The router will send out routing protocol updates (e.g., OSPF LSAs, EIGRP queries) to re-learn routes. In some IOS versions, the command may also clear the FIB (Forwarding Information Base) and CEF (Cisco Express Forwarding) tables, which can cause a brief interruption in packet forwarding. This command is a fundamental tool for any CCNA or CCNP candidate to understand, as it demonstrates the dynamic nature of routing and the importance of convergence.
clear ip route *When to Use This Command
- After making major routing protocol configuration changes to force immediate route recalculation
- When troubleshooting routing loops or stale routes that are not being updated automatically
- Before performing a routing protocol convergence test in a lab environment
- When a router has incorrect routes due to a routing protocol malfunction
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| * | * | The asterisk wildcard indicates that all routes in the IP routing table should be cleared. No other parameters are accepted with this command. Using the asterisk is the only way to clear the entire table; attempting to use a network address with a mask will result in a syntax error. Common mistake: forgetting the asterisk or using a specific route parameter, which is not supported. |
Command Examples
Clear entire IP routing table
clear ip route *Router# clear ip route * Router#
No output is displayed after the command. The prompt returns immediately, indicating the routing table has been cleared. Use 'show ip route' to verify the table is empty and being repopulated.
Verify routing table after clearing
show ip routeCodes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
C 10.0.0.0/24 is directly connected, Serial0/0/0
L 10.0.0.1/32 is directly connected, Serial0/0/0
O 172.16.0.0/16 [110/2] via 10.0.0.2, 00:00:05, Serial0/0/0After clearing, only directly connected and local routes appear immediately. OSPF routes (O) are repopulated after neighbor adjacency re-establishment. The '[110/2]' shows administrative distance (110 for OSPF) and metric (2). '00:00:05' indicates the route age in hours:minutes:seconds since learned.
Understanding the Output
The 'clear ip route *' command itself produces no output. To verify the effect, use 'show ip route'. Initially, only directly connected (C) and local (L) routes appear.
Over time, routes from dynamic routing protocols (e.g., O, D, R) reappear as the router re-establishes neighbor relationships and exchanges routing information. Key fields in 'show ip route' output: the code (C, O, D, etc.) indicates the route source; the network address and prefix length (e.g., 192.168.1.0/24); for non-connected routes, the administrative distance and metric in brackets (e.g., [110/2]); the next-hop IP address (via); the route age; and the outgoing interface. A missing route that was previously present indicates a problem with the routing protocol or connectivity.
Watch for incomplete routing tables or missing routes after clearing, which may indicate configuration errors or network issues.
Configuration Scenarios
Clearing the entire routing table after a routing protocol flap
After a major link failure and recovery, the routing table may contain stale or inconsistent routes. This scenario demonstrates clearing the entire table to force a fresh convergence.
Topology
R1(Gi0/0)---10.0.12.0/30---(Gi0/0)R2
R2(Gi0/1)---192.168.1.0/24---(Gi0/0)R3Steps
- 1.Step 1: Enter privileged EXEC mode: Router> enable
- 2.Step 2: Verify current routing table: Router# show ip route
- 3.Step 3: Clear the entire IP routing table: Router# clear ip route *
- 4.Step 4: Wait for convergence (monitor with debug or show commands)
- 5.Step 5: Verify the routing table is rebuilt: Router# show ip route
! No configuration changes are made; this is an exec command. Router# clear ip route *
Verify: Use 'show ip route' to confirm that routes are repopulated. Expected output shows routes learned via routing protocols (e.g., OSPF, EIGRP) and directly connected networks. For example: Codes: C - connected, S - static, O - OSPF, E - EIGRP C 10.0.12.0/30 is directly connected, GigabitEthernet0/0 O 192.168.1.0/24 [110/2] via 10.0.12.2, 00:00:05, GigabitEthernet0/0
Watch out: A common mistake is not waiting for convergence before testing connectivity. Immediately after clearing, all routes are gone, causing traffic drops. Always verify that routing protocols have re-established adjacencies and routes are learned.
Clearing the routing table to resolve a routing loop caused by a misconfigured static route
A misconfigured static route pointing to an incorrect next-hop can cause a routing loop. Clearing the routing table removes the problematic entry and forces the router to rely on dynamic routes.
Topology
R1(Gi0/0)---10.0.12.0/30---(Gi0/0)R2
R1 has a static route: ip route 192.168.2.0 255.255.255.0 10.0.12.2 (correct)
But also a misconfigured static: ip route 192.168.2.0 255.255.255.0 10.0.12.3 (wrong)Steps
- 1.Step 1: Enter privileged EXEC mode: Router> enable
- 2.Step 2: Identify the problematic route: Router# show ip route 192.168.2.0
- 3.Step 3: Clear the entire routing table to remove the bad static route: Router# clear ip route *
- 4.Step 4: Verify that the correct route is learned (e.g., via OSPF): Router# show ip route 192.168.2.0
- 5.Step 5: If the bad static route reappears, remove it from configuration: Router(config)# no ip route 192.168.2.0 255.255.255.0 10.0.12.3
! Before clearing, the misconfigured static route is present in running config. Router(config)# ip route 192.168.2.0 255.255.255.0 10.0.12.3 ! After clearing, the route may be learned dynamically. To permanently fix, remove the bad static. Router(config)# no ip route 192.168.2.0 255.255.255.0 10.0.12.3
Verify: Use 'show ip route 192.168.2.0' to see the source of the route. Expected output shows the correct next-hop and protocol (e.g., OSPF). For example: Routing entry for 192.168.2.0/24 Known via "ospf 1", distance 110, metric 2 Last update from 10.0.12.2 on GigabitEthernet0/0
Watch out: Clearing the routing table does not remove the misconfigured static route from the running configuration. The static route will be re-installed after the clear if it remains in the config. Always remove the bad static route configuration to prevent recurrence.
Troubleshooting with This Command
When troubleshooting routing issues, the `clear ip route *` command is a last resort due to its disruptive nature. However, it can be invaluable when the routing table is corrupted or when routes are not updating correctly. Healthy output from `show ip route` shows a consistent set of routes with appropriate administrative distances and metrics, and all expected networks are reachable. Problem indicators include missing routes, routes pointing to unreachable next-hops, multiple routes to the same network with unexpected metrics, or routes that are stuck in an active or possibly down state. For example, if an OSPF route shows as 'O' but the next-hop is unreachable, or if an EIGRP route shows as 'D EX' (external) but should be internal, these are signs of a corrupted table.
Common symptoms that this command helps diagnose include: (1) Routing loops where packets are forwarded back and forth, indicated by high CPU usage and TTL exceeded messages. (2) Suboptimal routing where traffic takes a longer path than expected. (3) Inconsistent routing tables across routers in the same domain. (4) Routes that are not being updated after a topology change, even though routing protocol adjacencies are stable.
A step-by-step diagnostic flow for a network engineer would be: 1. Verify the routing table with `show ip route` and look for anomalies. 2. Check routing protocol neighbors with `show ip ospf neighbor` or `show ip eigrp neighbors` to ensure adjacencies are up. 3. Examine the routing protocol database with `show ip ospf database` or `show ip eigrp topology` to see if the router is receiving the correct information. 4. If the database is correct but the routing table is not, consider clearing the routing table. 5. Before clearing, document the current routing table for comparison. 6. Issue `clear ip route *` and immediately monitor the router's behavior. 7. After a few seconds, use `show ip route` to see if routes are repopulated correctly. 8. If routes are still missing, check routing protocol configurations and neighbor relationships. 9. Correlate with other commands: `show ip protocols` to verify routing process parameters, `show interfaces` to confirm link status, and `debug ip routing` to see route changes in real-time (use with caution in production).
It is important to correlate the output of `show ip route` with `show ip cef` to ensure that the FIB is also updated. In some cases, clearing the routing table may not clear the CEF table; you may need to use `clear ip cef *` separately. Also, note that `clear ip route *` does not affect the ARP cache; if next-hop MAC addresses are stale, you may need to clear ARP as well.
CCNA Exam Tips
CCNA exam tip: 'clear ip route *' is a privileged EXEC command; you cannot use it in user EXEC mode.
CCNA exam tip: This command temporarily disrupts traffic because routes are removed; use with caution in production.
CCNA exam tip: The asterisk (*) is a wildcard; you can also clear specific routes (e.g., 'clear ip route 192.168.1.0') or routes from a specific protocol (e.g., 'clear ip route ospf *').
CCNA exam tip: After clearing, the router will not have a default route until it is learned or reconfigured; verify with 'show ip route'.
Common Mistakes
Mistake 1: Using 'clear ip route *' in user EXEC mode instead of privileged EXEC mode, resulting in '% Invalid input detected' error.
Mistake 2: Forgetting that clearing the routing table will drop all active traffic that relies on those routes until they are relearned.
Mistake 3: Assuming the command will fix routing issues without verifying that routing protocols are properly configured and neighbors are reachable.
clear ip route * vs show ip route
These two commands are frequently mentioned together because both involve the IP routing table, but one is used for display (show ip route) and the other for clearing (clear ip route *). Understanding their distinct purposes helps network engineers avoid accidentally disrupting traffic.
| Aspect | clear ip route * | show ip route |
|---|---|---|
| Scope | All routes in routing table | All routes (display only) |
| Configuration mode | Privileged EXEC | User EXEC or Privileged EXEC |
| Persistence | Temporary; routes rebuilt | None; read-only output |
| Precedence | Destructive; removes entries | Non-destructive; safe |
| Typical use | Troubleshooting or resetting | Verification and debugging |
| Risk | High; traffic interruption | None |
Use clear ip route * when you need to force the router to flush and re-learn the entire routing table, typically after major topology changes or to clear corrupted entries.
Use show ip route when you need to verify the current routing table, check specific routes, or diagnose routing issues without altering state.
Platform Notes
In Cisco IOS-XE (e.g., Catalyst 9000 switches, ISR 4000 series), the `clear ip route *` command behaves identically to classic IOS. However, IOS-XE uses a modular architecture, and clearing the routing table may trigger a restart of the routing protocol processes in some implementations. The syntax is the same: `clear ip route *`.
On NX-OS (Nexus switches), the equivalent command is `clear ip route *` as well, but NX-OS uses a different routing table structure (URIB). The command works similarly, but note that NX-OS may require you to also clear the FIB with `clear ip fib *` if routes are not being forwarded correctly. On ASA firewalls, the command `clear ip route *` is available in the ASA OS (version 8.4+), but the ASA uses a security-centric routing model; clearing the routing table can impact VPN and NAT traffic.
The syntax is the same. For IOS-XR (e.g., ASR 9000, CRS), the command is `clear route *` (without the 'ip' keyword) in XR mode. IOS-XR uses a different routing infrastructure (RIB), and the command is `clear route ipv4 *` or `clear route *` depending on the version.
Behavior differences between IOS versions: In IOS 12.x, the command clears only the IP routing table, while in 15.x and 16.x, it may also clear the FIB and CEF tables. In some 15.x versions, there is a known issue where `clear ip route *` does not clear routes learned via BGP; you may need to use `clear ip bgp *` separately. Always check the specific IOS version documentation.
In general, the command is supported across all major Cisco platforms, but the impact and associated behaviors can vary slightly.
Related Commands
clear ip ospf process
Resets all OSPF processes, tearing down all neighbour adjacencies and flushing the LSDB, forcing OSPF to re-elect the DR/BDR and rebuild the routing table from scratch.
show ip route
Displays the IP routing table showing all known routes, their source protocols, administrative distances, metrics, next-hops, and outgoing interfaces.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions