IOS: Clearing an Interface Configuration

Interface is full

This occurs most commonly when you are labbing or testing something and an interface ends up with a lot of configuration, possibly something like the following:

Router(config-if)#do sh run int fa0/0
Building configuration…

Current configuration : 320 bytes
!
interface FastEthernet0/0
description Show the Default command
ip dhcp relay information trusted
ip address 198.18.56.1 255.255.255.0
no ip route-cache cef
no ip route-cache
ip ospf authentication-key MYOHMY
ip ospf network point-to-point
ip ospf hello-interval 20
duplex half
standby 1 ip 198.18.54.90
end

Router(config-if)#

You want to clear this configuration and reuse the interface for some other task. Normally you would need to issue a the “no” command for each line.

The ‘default’ command

The default command has many uses, and this is only one of them, but possibly it is the most useful.

Router(config-if)#default interface fa0/0
Building configuration…

Interface FastEthernet0/0 set to default configuration
Router(config)#do sh run int fa0/0
Building configuration…

Current configuration : 61 bytes
!
interface FastEthernet0/0
no ip address
duplex half
end

Router(config)#

That’s it. Simple and elegant.

Other posts in the series

  1. Cisco IOS CLI Regex: sh ip bgp in
  2. IOS CLI Tip: More accurate pipe commands
  3. Cisco Nexus NXOS and Fixing broken “switchto” syntax with alias
  4. show ip eigrp topology all
  5. Cisco IOS CLI Shortcuts
  6. The poor man's IOS Traffic Generator
  7. IOS: "terminal monitor" on, off - logging to your terminal
  8. IOS: Console, Terminal, Monitor, VTY - what is what ?
  9. IOS: Clearing an interface configuration (This post)
  10. IOS: Setting Terminal Window Length
  11. IOS CLI: show run linenum
  12. IOS: Setting the TCP timeout on IOS
  13. IOS: enable and .... disable ?
  14. IOS: Reverse SSH console access - Part 2
  15. IOS:Open Source Lab DNS and IP addressing
  16. IOS: Reverse SSH console access
  17. ip tcp timestamp
  18. Cisco ASA and IOS command tip - test aaa-server
About Greg Ferro

Greg Ferro is a Network Engineer/Architect, mostly focussed on Data Centre, Security Infrastructure, and recently Virtualization. He has over 20 years in IT, in wide range of employers working as a freelance consultant including Finance, Service Providers and Online Companies. He is CCIE#6920 and has a few ideas about the world, but not enough to really count.

He is a host on the Packet Pushers Podcast, blogger at EtherealMind.com and on Twitter @etherealmind and Google Plus

You can contact Greg via the site contact page.

Comments

  1. Beware of it on production switches, though! By default, switchports are not shutdown and defaulting will make them come up, possibly in the wrong VLAN. Of course, STP should not make this too dangerous, but it’s a good thing to be aware of. What I usually do is:

    default interface X
    interface X
    shutdown
    ! whatever else I need to do

  2. I had to teach that one to some of our new boys this past week.

    You can also use the range directive to reset configs on a whole mess of ports.

    Router(config)#default int range f0/0/0 – 4

    Or something like that.

  3. I also like using it with the individual interface commands, if I only want to “default” something on an interface:

    conf t > int f0/0 > default speed > default duplex

  4. Marko, I just tested default interface command on my 6500, and it *does* retain the shutdown/noshutdown state of the interface. Everything else was “defaulted”.