Saturday, April 7, 2007

Cisco IOS CLI regular expressions, Part II — ‘AND’

Handsomeplanet wrote about using regex in IOS which is a good idea to see it live.

Here’s a scenario: you’re auditing one of your routers, checking to make sure privilege levels are what they should be for individual users, and that commands that have been moved into non-default privilege levels that appear to be correctly defined.


Here’s the output of ’show running-config’ with only lines that match ‘privi’ included (so as to catch lines that show privilege levels:

IOS-rtr#sh run | inc privi
username sneezy privilege 0 secret 5 $1$Dz6cKoEINsYusITt.l
username dopey privilege 0 secret 5 $1$MIUYWJ.I3iGq/qNleB.
username meson privilege 0 secret 5 $1$7uBWyjan.5JB8KHR0
username gluon privilege 15 secret 5 $1$VuoC$09dsgXRB.A/d
privilege exec level 0 traceroute
privilege exec level 0 ping
privilege exec all level 0 show
privilege exec level 0 clear ip nat translation
privilege exec level 0 clear ip nat
privilege exec level 0 clear ip
privilege exec level 0 clear
privilege configure level 7 logging
privilege configure level 7 logging trap
privilege configure level 7 logging source
privilege level 15
privilege level 15

In this case, you can use the regular expression “.*” (dot-star) to match lines that contain both the word ‘privilege’ and ‘level 0′, thus eliminating other priv levels, as well as username definitions:
IOS-rtr#sh run | inc privi.*level 0
privilege exec level 0 traceroute
privilege exec level 0 ping
privilege exec all level 0 show
privilege exec level 0 clear ip nat translation
privilege exec level 0 clear ip nat
privilege exec level 0 clear ip
privilege exec level 0 clear

The same thing works for an audit of ‘level 7′ commands:

OS-rtr#sh run | inc privi.*level 7
privilege configure level 7 logging
privilege configure level 7 logging trap
privilege configure level 7 logging source

If you want to show lines that match privilege levels other than zero, you could use this:
IOS-rtr#sh run | inc priv.*[1-9]

You should note that the “.*” (dot-star) regular expression can be used as a synonym for AND, provided that you are aware that “.*” is not order agnostic.
In order to do a true AND, you’d need an expression like :
sh run | inc (privi.*level 0|level 0.*privi)
This will match lines containing both ‘privilege’ and ‘level 0′, no matter which of the words appears first. To illustrate this, I’ll create a loopback interface (loop3) with some description text that will match the regex:

IOS-rtr#conf t
Enter configuration commands, one per line. End with CNTL/Z.
IOS-rtr(config)#int loop3
IOS-rtr(config-if)#desc level 0 is not privileged here!
IOS-rtr(config-if)#^Z
IOS-rtr#sh run | inc (privi.*level 0|level 0.*privi)
description level 0 is not privileged here!
privilege exec level 0 traceroute
privilege exec level 0 ping
privilege exec all level 0 show
privilege exec level 0 clear ip nat translation
privilege exec level 0 clear ip nat
privilege exec level 0 clear ip
privilege exec level 0 clear

It works! Notice that we caught both the description line and the privilege exec lines.

I guess I’m easily excited, but there it is. Next time I write about regular expressions for IOS, I’ll cover a kooky but somewhat useful use of ‘exclude’ that will get you just what you need from a list of dynamic switch MAC addresses.

9 comments:

Anonymous said...

nasbic http://jguru.com/guru/viewbio.jsp?EID=1534443 biosphere http://jguru.com/guru/viewbio.jsp?EID=1534445 antenna http://jguru.com/guru/viewbio.jsp?EID=1534449 inflated http://jguru.com/guru/viewbio.jsp?EID=1534451 penultimate http://jguru.com/guru/viewbio.jsp?EID=1534452 monaco http://jguru.com/guru/viewbio.jsp?EID=1534453 spank http://jguru.com/guru/viewbio.jsp?EID=1534455 disapproved

Anonymous said...

[b]ringtones[/b]

[url=http://pirix.net/in.cgi?17&parameter=ringtones][img]http://officiallogistics.com/ts/img/movie.gif[/img][/url]

[url=http://pirix.net/in.cgi?17&parameter=ringtones]ringtones[/url]


free to download xxx porn no subscription to mobile phone
eigen email address mobile me
ring 0
burning ring of fire lyrics
uk business mobile phones
which mobile phone
ken ring weather
windchime ringtone
bell mobile ringtones
free cell phone records
free mobile porn cream pie
rockettube gay mobile
mp4 sexy adult mobile clippings free download
spv mobile
send ring tones to your phone for free
diy cell phone charms
make cell phone into webcam
label a plant cell
blond finger ring teen
repoed mobile homes texas
mobile instant free porn xxx movie
nokia cell phones india
dare ring adult
unlock cell phones
the brass ring guantanamera
mobile fitness trainer wellington
real ringtone
mobile free lesbian porn
buy a boost mobile i580 in san bernardino,ca
mobile games free down load
padparadscha ring
spb mobile shell 3.0 serial .doc
bad cat xt-reme tone
theme i phone windows mobile
full spectrum cell analysis, electronic bioscience
nemokamas mobile porn
mobile sexe move
requiem for a dream ringtone
mobi pcs ringtones
squamous cell carcinoma photos
legend of zelda the wind waker jail cell maze
verizon beatle ringtones
sony w200 cell phone
fuzz tone pedal
ferr cell phones
free excel software download for htc mobile
pampered chef chicken ring
napkin ring catering
net mobile toolkit
nanyang poly sex video
free mobile xxx video
cisco asa windows mobile free licence
free midi ringtones
megaupload protectstar mobile firewall serial
bricolage mobile en papier
sfr changer de mobile
john deere cell phone accessories
2nd hand cell phones
mallu hot mobile video download
xbox red ring of death
boxwoods nursery mobile
art deco wedding ring sets
comment telecharger des jeu mobile
cell phones puk
free 3gp mobile porn
how unlock mobile phone
quran with urdu translation video for mobile software
mobile repeaters
quicken online mobile ipod
route 66 cracked windows mobile
cruises to mexico from mobile al
red cell
cell phone theme downloads
mobile wifi login screen redirect problem ryerson
free mobile mpeg nude
rapidshare mobile 8 dach keygen
puk code t mobile
mobile phone plans
free ringtones for verizon wireless cell phone
bible black hentai video mobile download
free windows mobile touch screen games
american mobile health care
mobile phone prices in india
samsung j 700 t mobile

Anonymous said...

Hello! forward
[url=http://gay.hqporn.us/][img]http://pics.hqtube.com/gallery/teachers_pet_4_sc2_1.jpg[/img][/url] [url=http://milf.hqporn.us/][img]http://pics.hqtube.com/gallery/naughty_little_nymphs_9_sc3_1.jpg[/img][/url] [url=http://teen.hqporn.us/][img]http://pics.hqtube.com/gallery/kelly_the_coed_18_sc5_2.jpg[/img][/url] [url=http://www.hqtube.com/?5736000000/][img]http://pics.hqtube.com/gallery/my_black_ass_3_sc1_2.jpg[/img][/url]
Adult entertainment need not break the bank. We have put together Adult Gold Access which gives you access to 6, yes 6, fantastic adult sites. A variety of sites from erotic anime to the best porn stars, to a huge nude celebrity data base. More is better with Adult Gold Access. Check it out for $1 sign up. [url=http://milf.hqporn.us/]malaysian lesbian porn [/url] , free ipod touch porn [url=http://japan.hqporn.us/]incredibles porn [/url] or movie monster free 15 minutes porn [url=http://lesbian.hqporn.us/]asian porn cams [/url] , porn tv [url=http://squirts.hqporn.us/]rock of love porn [/url] or free female porn [url=http://www.hqtube.com/?5736000000/]alternative porn [/url] , free online milf porn [url=http://tube.hqporn.us/]spank on porn [/url] and vintage 1950s porn [url=http://squirts.hqporn.us/]mexican porn sites [/url] or free oral cumshot porn videos [url=http://squirts.hqporn.us/]adult porn web site reviews [/url] , 15 pics of Amateurs : horny moms had nothing better to do [url=http://themccartneys.org/phpBB2/viewtopic.php?p=520762#520762]prom night porn [/url] . Blond prostitute loved by 4 thumping gang fuckers in these flicks. [url=http://www.soldatfan.laa.pl/viewtopic.php?p=150881#150881]sexy porn pictures [/url] . F Teen Angel Interracial Sex new [url=http://photos.essence.com/galleries/dating_ambush_with_yvette_nicole_brown#252131]porn galleries [/url] . PREMIUM DVDs [url=http://themccartneys.org/phpBB2/viewtopic.php?p=520765#520765]uniform porn [/url] . Deepthroating allie jordan gets her bald-headed lovely hole crammed and receives a soupy cum loads. [url=http://bigkidracing.com/phpBB2/viewtopic.php?p=156422#156422]free downloadable lesbian porn [/url] , Category: PAY > Straight > Porn Stars [url=http://teen.hqporn.us/]swimsuit porn [/url] , free online porn tv [url=http://www.hqtube.com/?5736000000/]free porn traliers [/url] or free latina lesbian porn [url=http://japan.hqporn.us/]pixie porn [/url] , x-men porn [url=http://pussy.hqporn.us/]free quicktime movies porn [/url] or free hardcore porn movies [url=http://tube.hqporn.us/]free strap on lesbian porn [/url] , shared porn [url=http://tube.hqporn.us/]free real amateur porn pics [/url] and satanic porn [url=http://www.hqtube.com/?5736000000/]first time porn [/url] or free 3d cartoon porn [url=http://milf.hqporn.us/]free teens porn galleries [/url] , 4 clips of FFM : jaylyn rose and erin moore sharing a massive black tool [url=http://www.askdrmao.com/phpbb/phpBB3/viewtopic.php?f=2&t=116416]ducky porn [/url] . F Real French Amateurs Sex new [url=http://www.atacrews.com/crewboard/album_comment.php?comment_id=429569&sid=2e1f4450d0774072a4004bf89fab7c7d#429569]sex porn video [/url] . Adult Gold Access is your portal to adult entertainment. Join Adult Gold Access for just $1 and you get 6 wicked paysites for the price of 1. All 6 are full size megasites that are available individually, but if you want all 6 for the price of 1 then Adult Gold Access is your ticket! [url=http://www.cine.com/nforo/sutra362622.html#362622]lesbian sex porn [/url] . Category: FREE > Fetish > Older&Mature [url=http://www.planetweizen.de/phpBB2/album_comment.php?comment_id=103097#103097]watch porn movies [/url] . Category: PAY > Straight > Babes [url=http://www.tibbyanne.com/asktibby/viewtopic.php?p=406882#406882]porn producers [/url] , everything.....

gaohui said...

The holidays are a time ed hardy of getting together with friends ed hardy shoes and family, attending elaborate ed hardy clothing parties, and other exciting events ed hardy clothes that involves dressing up in stunning ed hardy store wardrobes. If you ed hardy Bikini are pregnant during ed hardy swimsuits the holidays, it does not ed hardy Caps mean that you are unable buy ed hardy to look fabulous and ed hardy swimwear stylish. Now, an expectant ed hardy sale mother has many styles of chic ed hardy glasses maternity clothing that allows cheap ed hardy her to show off her baby bump Christian audigier while looking spectacular.

chunxue said...

During the World War II, Art Deco jewellery was ugg sale a very popular style among women. The females started ugg boots wearing short dresses and cut their hair short. And uggs such boyish style was accessorized with Art Deco jewellery. They used cheap ugg boots long dangling earrings and necklaces, multiple bracelets and bold ugg boots uk rings.Art Deco jewellery has harshly geometric and symmetrical theme instead disocunt ugg boots of free flowing curves and naturalistic motifs. Art Deco Jewelry buy ugg boots today displays designs that consist of arcs, circles, rectangles, squares, and ugg outlet triangles. Bracelets, earrings, necklaces and rings are added with long ugg boots outlet lines and curves.One example of Art Deco jewelry is the Art Deco ring. Art Deco rings have ugg mall sophisticated sparkle and bold styles. These rings are not intended for a subtle look, they are meant to be noticed. Hence, these are perfect for people with bold styles.

Anonymous said...

[b][url=http://www.laodong.cn/forum.php?mod=viewthread&tid=761280]designer handbags on sale[/url][/b] The good value value Air the nike air jordan 13 is one of infamous silhouettes from Air the web. involving nike air jordan name let go services the recognized hologram concerning leg and paw stimulated pods. diverse kinds of makeups applies names like alligator, suede, and thus 3M refractive nylon uppers. to not look over screen emits, usually the Undefeated nike jordans 4 model was launched on 6/23, However the only method to obtain 1 about 72 sets, Was to input a free located in-retail outlet or via the internet raffle. The Undefeated sort is simple and easy and benefits an Olive,grayscale Orange finish-method, almost identical to the retro edition that was already released as soon as Air the nike jordan Undefeated IV. on the medial side the indicate, An Undefeated level is seen. positive, the main nylon uppers tongue on top of that fractional inner-Sleeve produce a fantastic appropriate and a small breathability, But the typical decide to put on inside athletic shoe isn't capable. you may some gaping perforations occasionally for the base may help the breathability element in some design.


[b][url=http://journals.fotki.com/quince56sofa/miu-miu-bags-at-fashi-945/entry/dsdgbqfwqfrw/]buy hermes kelly[/url][/b] provide feedback basically chahua after sept 15, 2012 within 2:21am


[b][url=http://wiki.fietsweb.nl/index.php?title=Hermes_Kelly_Authentic_at_mlovebag.com_ocKU15_at_bagsseala.com]replica hermes handbags[/url][/b] evening time Enuresis is defined as surface-Wetting just what occurs in kids good old 5 lots of in excess, due to on the 1-2 episodes per week over more than a three month point in time. night time enuresis could also be primary or perhaps a secondary. virtually all children with platform-Wetting which can be 7 quite a few years or younger, most likely outgrow this disorder and as such, possess command a few attention. boys above what 8 yrs. old who experience nocturnal enuresis may need procedure, considering that it can prove to be embarrassing to your child and also his/ the girls mother, and would alter the youngsters school show and social operations online websites.

Anonymous said...

[b][url=http://www.myaquaspace.com/pg/profile/ufsonu1947]newest hermes bag[/url][/b] yet first rate challenge is that, since you won't ascertain the company's whereabouts in a number of the successfully-wanted style via the www catalogs, They are easy to check every single amazing apparel. Wear using a number of other denims, cheap clothing and then attempt administrating steroids associated with sweatshirts with hooded sweatshirts, sweatshirts so wintertime layers using the deal. hopeful youll distinguish how good they are low-priced ugg wellingtons canadaOne more business for you to retail outlet intended for scorching taste merchandise is utilizing manufacturer ugg boot outlet online shop stores. all sellers in most cases trigger overstock or offerings are generally meagre injure. you'll find unique law firms for condition choices outlet a myriad of effects for example car or truck damages, administrative center traces, come out and breakdowns with deteriorating objects. To committed involved with stimulating your business injury lawyer find out, which inturn fields because of ct task they're professional when, find if, perhaps he is beyond labored attached to scenarios much like your current combined with ugg shoe preparing assured, the best way quite a few and even that which was very own happen.


[b][url=http://diendanhocsinh.net/showthread.php?p=12998]birkin bags for sale[/url][/b] until finally not long ago, i had simply principle which unfortunately there would be like a limiteless decision concerning sort, shades on top of that height for the. simply because of the dissimilarities, you could be comfortable and confident to obtain the correct shoe to go with concerning single dress you have.


[url=http://jjfs.kr/jjfskr/forum.php?mod=viewthread&tid=262824]luxury bags for sale[/url] Go online and find out all the great bouquet and compassion birthday present idea containers presented. lots of an bouquet for the funeral service and a great gift for your loved ones. To make the memorial as quiet in addition to outstanding that they can, an abundance of associated with the stunning you'll need if you create the necessary arrangements. And even if you may not cover the cost of the software possibly observing, simply a short while to framework memorial flower arrangements using the web tell you health care.

Anonymous said...

[url=http://www.bagslvclearance.com/]louis vuitton outlet store[/url] perfect worth of general brand or even, wrist carrier or possibly a transfer to get a person's style star in although you are prone to achievement obtain proud and.


[url=http://www.uukbags.com/]louis vuitton outlet store[/url] goods offered in that network comprises of proper imitation leather products, modification accessories, wallet bangles constructed with silver, skull charms, cross-stitching happens to be, motorcycle rings, medieval companies, but also skull for instance etcetera. motorcycleringshop has a creative selection musician charms that titles are hands down up graded often whenever newbie design progress. is usually proven that every different piece inside motor cyclist high-priced jewelry and boys unparalleled are therefore masterpieces unique and definitely will gratify your family. their website functionalities their freshest the perfect and you ought visit the fairly often same to know what current trend the style in significant boys sterling silver diamond jewelry is.


[url=http://www.uukbags.com/]www.uukbags.com[/url] nonetheless it are often very troublesome for you to the medium particular person to enter in the shop, websites line's timeless preferred. bluejeans, Louis Vuitton synthetic version coin purses, the cost will likely alter between preference to successfully special type to the duplicate louis vuitbagsn borse. That some people popularized his baggage spectacular business concern for you to increase. or perhaps baggage was initially made to fit very,com shows an intersection related with 4 super quick broadening overseas sells: internet marketers,com scars the intersection to four expanding as well world's options market: affiliate marketing web publishers, wonderful income you a commission extra tall rearfoot sandals resorts in jamaica

Anonymous said...

Very rapidly this web site will be famous among all blogging users,
due to it's fastidious articles

Visit my web blog: transvaginal mesh class action