Archive for April, 2008

Tip of the Day – ACL Renumbering

As most know current versions of IOS have numbered ACLs allowing for each inserting of new rules. For example:

Extended IP access list SAMPLEACL
10 permit ip 10.1.25.0 0.0.0.255 any
20 permit ip 10.1.50.0 0.0.0.255 any
30 permit ip host 10.1.10.15 any
40 deny ip any any log

This means you can just put a 15 in front of your new statement and the rule will be added between 10 and 20. This works great and upon reloading of the device the ACLs become renumbered and all is well. The thing is what happens if you want to insert more than 10 entries between two existing entries? What about if you are an anal retentive person who just wants to see it all nice and spaced apart but you don’t want to reload your device? There is a simple answer. From the configure mode enter the following command:

ip access resequence SAMPLEACL 10 10

This tells the device to renumber the ACL named SAMPLEACL, start with the number 10 and increment lines by 10. You can play with these numbers to get it to generate all sorts of numbers but I personally just stick to 10/10.


Website Spotlight – yougetsignal.com

yougetsignal.com

Every Network Engineer has a series of websites tucked away in their pocket for various reasons. This website is one that I recently stumbled upon. I first found this site off a search on Google. I was trying to reverse an IP to a hostname to determine a website that was being accessed. Unfortunately the server was using virtual hosting so it wasn’t as easy as an nslookup. This is where this site came into play.

Not only does this site have a tool to give you a list of websites hosted on a particular IP but it also allows you to run traceroutes, track down the physical location of an IP and even a telephone number. There are even ways to add this to your Windows Vista Sidebar or iGoogle homepage.

I highly recommend you take a quick look and see what you think.

http://www.yougetsignal.com


Session Control Keys

Most of us spend a decent amount of each day poking around inside a switch or router. While in there we type various commands and inevitably miss a keystroke or want to change what we typed. Most people seem to favor the backspace here but I personally favor the session control keys. Just like a linux/unix session there are a series of control keys that allow you to do things other than delete what you have typed one character at a time.

Key Combination Description
Press Ctrl-A Moves to the beginning of the line.
Press Ctrl-B Moves back one character.
Press Esc-B Moves back to the previous word.
Press Ctrl-D Deletes the character at the cursor position.
Press Ctrl-E Moves to the end of the line.
Press Ctrl-F Moves forward one character.
Press Esc-F Moves forward one word.
Press Ctrl-K Deletes all characters from the cursor to the end of the line.
Press Ctrl-U or Ctrl-X Deletes all characters from the cursor to the beginning of the line.
Press Ctrl-W Deletes a single word.

Take some time and play around with these. I am sure you will find a few favorites and with any luck it will help a little bit of your sanity.


Output Modifiers and their Regular Expressions

The one thing that doesn’t seem to be covered be by Cisco very well is that they support full regular expressions with the output modifier commands. Some of the more complex regular expressions seem to be a bit hit or miss but for the most part the all seem to be work. If you want to learn about the power of Regular Expressions then go search Google. If you want to learn a few quick tricks that you can use then this post is for you!

The Parathesis

To start with you need to know about ( and ). These are not required for simple regular expressions but please keep in mind that if you want to run complex, multiple step regular expressions you will need to encapsulate the expressions within a ( and ).

ValueA OR ValueB

This is one of the most basic regular expression. Many times you might want to return results that match A or B and not just A and just B. To do this simply format your expression like:

ValueA|ValueB

This will return results that match both ValueA and ValueB.

The Character Wild Card

If you want to put a character wildcard you can do so by using a period . for the character you wish to be a wildcard. The important thing to remember is this is a character wildcard and not a string wildcard. This means if you want to match either port, import, export, or report you will need to use the following wildcard:

p..t

You will notice there is two periods one for the first and one for the second character. If you don’t include both the periods you won’t match any of the words.

Limited Character Wild Card

If you wish to match import, export but not report or deport. You can do this by using a limited wild card setup. In this case you would specify the following:

[mx]port

Basically you put the character matches you want to between a [ and ].

The Optional Character

If you want to setup a pattern where you don’t have to match one of the characters you can use the optional character expression. Simply place a ? after the character that isn’t required. For example if you wish to match color and colour you can simply use the following expression:

colou?r

This makes the u an optional character.

These are the most common regular expression that I have found useful in my daily adventures. There are a bunch of other expressions you can use and I have over simplified some of these commands to try and keep it as simple as possible. Like I said earlier I would check Google for tutorials on regular expressions. There are many great tutorials floating around.


An Introduction to Output Modifiers

Ask any experienced Cisco Engineer and they will tell you one of the basic commands they can’t live without is the output modifiers. While they aren’t required to get the job done they do make things easier at times. As you would expect output modifiers modify the output. If you are a linux/unix/bsd person you are most likely familiar with grep. This of the output modifiers as the grep for Cisco.

This is the first of a series of posts about output modifiers. To start with I am going to cover four basic output modifiers; include, exclude, begin and section. In future posts I will cover the other modifiers and some advanced patterning. As with most Cisco features and commands not all modifiers will be available on all platforms and versions.

include

This modifier only returns lines that match the pattern given. This is useful for requiring quick pieces of information from the configuration and other output heavy commands. Some of the modifier variations I use often are:

show version | include ID
show frame pvc | include rate
show running-config | include alias

I would recommend you play around with this modifier as I am sure you can come up with some great variations of this.

exclude

As you have probably gathered this is the absolute opposite of the include modifier. I don’t use this modifier nearly as much as include but one of the great uses is to look at your processes and how much cpu they are consuming. If you have ever looked you will find a very large number of processes of which most are using no resources. Using the following command will only show you processes that actually use resources.

show processes cpu | exclude 0.00%__0.00%__0.00%

If you compare the two outputs you will notice the exclude modifier greatly reduces the output. I would recommend making an alias in your device for this command as it is quite long to type and if your device is truly suffering a cpu resource issue the last thing you want to do is type a long command.

begin

If you want to jump to a section of configuration without having to smash the space bar a bunch of times you can just use the begin modifier. If you are looking at a high density switch such as a 3750, 4500 or 6500 this can be useful to jump to the various switches/blades. For example:

show running-config | begin FastEthernet2/0/

There isn’t much more to be said about this modifier. It is fairly straight forward.

section

This is very handy for getting sections of configuration. How many times do you want to look at a section of code such as an interface, controller, route-map or dial-peer without seeing the rest of the configuration. This modifier makes this very simple. For example:

show running-config | section controller
show running-config | section Serial
show running-config | section line

You will notice that this modifier is actually a superset of include as it will return any lines that matches the pattern but if that line is a section title it also includes the other lines in the section.