Save yourself some time with the default interface command
- How to |
- command line |
- Cisco
If you configure Cisco equipment on a regular basis, you might find yourself in a situation with a large number of router or switch ports that need to be reconfigured. There are several ways you can prep your switch ports to complete your task:
- You could do a "show run" and then build a script that includes the "no" form in front of each of the old commands, then apply your new script.
- You could simply overwrite the old config with the new and then go do the no form of the stuff you don't want after the fact.
- You could erase the startup-config then reload the switch and start from scratch (assuming the device isn't in production anymore).
There are probably another half dozen different ways of simply erasing the config and starting over, but there's one more option that this post is focused on today: the default interface command.
The Default command
The default command is Cisco's way of letting you set a specific part of the configuration back to the default without having to use the "no" form of commands a hundred times over. You may already be aware of this command, however if you are learning of this for the first time, you may be saying "No way! I've been doing it the slow way all these years!" - Read on and learn how to save yourself some time.
The default command is available for many configuration level commands as can be seen in the results below, however this post will be focusing specifically on the "default interface" command.
S1(config)#default ?
aaa Authentication, Authorization and Accounting.
access-list Add an access list entry
alias Create command alias
archive Archive the configuration
arp Set a static ARP entry
banner Define a login banner
beep Configure BEEP (Blocks Extensible Exchange
Protocol)
boot Modify system boot parameters
bridge Bridge Group.
buffers Adjust system buffer pool parameters
cdp Global CDP configuration subcommands
cef Cisco Express Forwarding
Output Truncated....
How to use the default command
The command is pretty easy to use. Simply enter global config mode and type the word default followed by normal interface syntax:
S1(config)#default interface FastEthernet 0/1
For demonstration purposes, here is some of the configuration before the default interface command is used:
Current configuration : 324 bytes ! interface FastEthernet0/1 description Host Port switchport access vlan 10 switchport mode access switchport voice vlan 20 switchport port-security maximum 2 switchport port-security switchport port-security mac-address sticky switchport port-security mac-address sticky 4032.52af.2344 spanning-tree portfast ! interface FastEthernet0/2 description Host Port switchport access vlan 10 switchport mode access switchport voice vlan 20 switchport port-security maximum 2 switchport port-security switchport port-security mac-address sticky spanning-tree portfast end
To clear out these interfaces one at a time, simply input the following:
S1(config)#default interface fastEthernet 0/1 Interface FastEthernet0/1 set to default configuration S1(config)#default interface fastEthernet 0/2 Interface FastEthernet0/2 set to default configuration
However, if you are editing a switch with a range of interfaces you want clear, the default command supports the interface range command. Here is a before/after demonstration:
S1#show int status Port Name Status Vlan Duplex Speed Type Fa0/1 notconnect 1 auto auto 10/100BaseTX Fa0/2 notconnect 1 auto auto 10/100BaseTX Fa0/3 Host Port notconnect 10 auto auto 10/100BaseTX Fa0/4 Host Port notconnect 10 auto auto 10/100BaseTX Fa0/5 Host Port notconnect 10 auto auto 10/100BaseTX Fa0/6 Data Ports notconnect 10 auto auto 10/100BaseTX Fa0/7 Data Ports notconnect 10 auto auto 10/100BaseTX Fa0/8 Data Ports notconnect 10 auto auto 10/100BaseTX Fa0/9 Data Ports notconnect 10 auto auto 10/100BaseTX Fa0/10 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/11 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/12 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/13 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/14 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/15 Server Ports notconnect 40 auto auto 10/100BaseTX Fa0/16 notconnect 1 auto auto 10/100BaseTX Fa0/17 notconnect 1 auto auto 10/100BaseTX Fa0/18 notconnect 1 auto auto 10/100BaseTX Fa0/19 notconnect 1 auto auto 10/100BaseTX Fa0/20 Uplink notconnect 1 auto auto 10/100BaseTX
Enter the default interface range command and see the results:
S1#conf t Enter configuration commands, one per line. End with CNTL/Z. S1(config)#default int range f0/1 -20 S1(config)#exit S1#show int status Port Name Status Vlan Duplex Speed Type Fa0/1 notconnect 1 auto auto 10/100BaseTX Fa0/2 notconnect 1 auto auto 10/100BaseTX Fa0/3 notconnect 1 auto auto 10/100BaseTX Fa0/4 notconnect 1 auto auto 10/100BaseTX Fa0/5 notconnect 1 auto auto 10/100BaseTX Fa0/6 notconnect 1 auto auto 10/100BaseTX Fa0/7 notconnect 1 auto auto 10/100BaseTX Fa0/8 notconnect 1 auto auto 10/100BaseTX Fa0/9 notconnect 1 auto auto 10/100BaseTX Fa0/10 notconnect 1 auto auto 10/100BaseTX Fa0/11 notconnect 1 auto auto 10/100BaseTX Fa0/12 notconnect 1 auto auto 10/100BaseTX Fa0/13 notconnect 1 auto auto 10/100BaseTX Fa0/14 notconnect 1 auto auto 10/100BaseTX Fa0/15 notconnect 1 auto auto 10/100BaseTX Fa0/16 notconnect 1 auto auto 10/100BaseTX Fa0/17 notconnect 1 auto auto 10/100BaseTX Fa0/18 notconnect 1 auto auto 10/100BaseTX Fa0/19 notconnect 1 auto auto 10/100BaseTX Fa0/20 notconnect 1 auto auto 10/100BaseTX
Voila! Your interfaces are now cleared of their configuration.
This also works with router interfaces
Here is the output from a 3725:
R1(config)#do show run int f0/0 Building configuration... Current configuration : 192 bytes ! interface FastEthernet0/0 description Server LAN ip address 10.0.0.1 255.255.255.0 ip access-group HTTP in duplex auto speed auto traffic-shape rate 50000000 1250000 1250000 1000 end R1(config)# R1(config)# R1(config)#default interface f0/0 Building configuration... Interface FastEthernet0/0 set to default configuration R1(config)#do show run int f0/0 Building configuration... Current configuration : 73 bytes ! interface FastEthernet0/0 no ip address duplex auto speed auto end
Note: The standard disclaimer applies here... Don't do this in production without thinking it through first. If you blow away configuration on a production switch and/or cause an outage with this command, it's not my fault. Etc, etc..
I hope this helps you save some time while configuring switch ports. If you are in the command line on a nearly daily basis, it should come in handy. Let me know in the comments below if this has helped you out.

Comments
Never seen this one before.
Never seen this one before. Will be a huge help - thanks for sharing!
Awesome!
Awesome!
Awesome
this is great !
Hey Adam, Nice post. I use
Hey Adam,
Nice post. I use this quite often when doing Frame>MPLS conversions. It's much easier than deleting everything unwanted. I build the interface in notepad first, default it, and plop it in. Its about a 10 second ordeal. :)
Amazing!
That is really cool! The most amazing thing I have ever seen on Cisco IOS. It is like magic...wowwww
Thanks for sharing
NX-OS
I Wish NX-OS had this. I have yet to see it in any of the versions I have work with.
Funny... I just saw my
Funny... I just saw my supervisor use this command the other day on an interface that while physically unplugged still showed Up/Up. But he did the command so fast and went on to configure another interface I really didnt get to see the command.. Thanks