I know we can use auto-completion (tab key) and abbreviated commands (such as sh ip int bri
) to speed up typing.
However, I'm still not satisfied with typing crypting chains such as sh ip dh sn bi | i 20.12
for show ip dhcp snooping binding | include 20.12
.
Can I define shortcuts for often used command sequences, and how?
Best Answer
We can use the
alias
command in global conf mode:<mode>
is one of the many IOS command modes. If you need it in different modes, you have to call it for each one - typealias ?
to get a long list of modes.An example for checking for a dhcp snooped IP, type in global conf mode
Now you can simply type
snoop 172.16.20.12
to check for this IP orsnoop 801
for checking all IPs in VLAN 801, for example. Do similarly forshow mac-address-table | include
and you're faster in searching and troubleshooting.Further tipps:
sh aliases
shows your aliases plus the predefined onesno alias <mode> <command>
can be guessed for removing an alias,no alias <mode>
deletes the aliases for a complete mode - so you can clear several at once,default alias <mode>
works similarly, as expected