Cisco ACL Test Scripts

W.T.F.

It has bothered me for a while that there seem to be no good tools for testing Cisco Access Control Lists (Cisco ACL Testers if you will). There are a couple of tools to build access lists interactively, even one that will run a simulation of a packet hitting the entries of a list which would be useful if you could enter an ACL by copy/pasting or importing from a Cisco config-like file, but you can't. This particular lack of tooling presents a significant problem when reviewing ACLs during troubleshooting or updating for new requirements, as soon as the ACL grows beyond 10 or so lines. This happens more frequently than a sane man can handle in my day-to-day job, and so I've drawn the line. Here are some tools I've hacked together to help me: if you do a job like mine, you might find them useful.

acltest.pl - Cisco ACL Tester

(Download: acltest.pl v0.0.0.11 - Updated March 2011)
(Sample HTML output: 'sources' search; 'both individual address elements' search using host elements; 'both individual address elements' search using network elements)

Description

acltest is a Cisco ACL Tester which identifies IP address matches from test input (1 or 2 IP addresses or network addresses) and an ACL in a format consistent with Cisco ACLs used in CatOS, IOS, NX-OS and on the ASA platform. The intent is to speed up the search for lines which a particular search address would match against by doing the leg-work of checking for overlap with address elements used in the ACL supplied while avoiding number-blindness when manually reviewing ACLs.

Dependencies

None.

Limitations

What it DOES do

Extensions

I've extended this script into a CGI which can be called with arguments in either GET or POST requests (GET requests are slightly limited due to maximum argument lengths). I'm calling it from a C# webapp which interrogates our Solarwinds NCMv6 database and then POSTs the various parameters. The webapp itself is fairly simple: just some database access code, a SQL query to return the most recent configuration for every device in the inventory, and a couple of Regexps to pull out ACLs and their names from a Cisco IOS/NXOS config which I've reproduced below. On our IIS installation, I simply changed the extension of the script to .plex and it executed happily.

Regular Expressions

Complete 'IP Access-List': ^(ip access-list\s+(extended|standard)?\s*([\w\d_-]+).*\n\s+.*)
Complete 'Access-List': ^(access-list\s+([\w\d_-]+)\s*.*(\naccess-list\s+\2.*)*)
'IP Access-List' names (may as well use the above one and pull out $3, or use this one and pull $2): ^ip access-list\s+(extended|standard)?\s*([\w\d_-]+).*(\n\s+.*)*
'Access-List' names (and comments if the 1st line is a remark - pull out $1 for name and if $2 is not blank, pull $3 for the comment): ^access-list\s+([\w\d_-]+)\s*(remark\s+(.*))?.*(\naccess-list\s+\1.*)*
ASA-style ACE: ^access-list\s+(?:[\w\d_-]+)\s+.*?(?:\bextended)?\s+)?(permit|deny)\s+

acl2filter.pl - Cisco ACL to TCPDump Filter

(Download: acl2filter.pl v0.0.0.3 - Updated June 2011)

Description

acl2filter is a Cisco ACL to TCPDump filter converter which reads an ACL in a format consistent with Cisco ACLs used in CatOS, IOS, NX-OS and on the ASA platform and outputs an equivalent string that can be used as a TCPDump filter. Intended use is for network administrators to test the effect of a Cisco ACL on a packet capture, either taken live from the wire (from a SPAN port, for instance) or from a pre-captured pcap.
ACLs can contain a 'log' keyword on individual lines to generate a message whenever those lines are hit. This is useful in many circumstances, not least when you need to (for instance) add an ACL to a VLAN which has been passing traffic uninterrupted for some time, and despite your best efforts you have no idea if you're going to block something that 'has always worked' (so you finish the ACL with 'permit ip any any log[-input]' and Robert's your father's brother: a log of all the stuff you haven't explicitly dealt with). Well, imagine if you will that some inconsiderate oik decided that performance trumps the ability to inspect processing operation and released a product that misleadingly allows the 'log' keyword to be used but won't actually report any matches. Well, such is the case with L2 ACLs on a physical interface. So how the shit do you deal with this? Well, kind sir, I offer a potential solution. Convert your ACL (minus the permit ip any any...) into a tcpdump filter, and use it to exclude all of the traffic it matches from packets processed by tcpdump. Initially I'll be applying this against a few days' worth of historical data to generate a PCAP of all unmatched (would be dropped if we turned the ACL 'on') traffic for review. In the future I'll probably use it to filter packets seen on a SPAN to do live-reviewing in Wireshark or tshark.

Dependencies

None.

Limitations

What it DOES do

Extensions

I've extended this script into a CGI which can be called with arguments in either GET or POST requests (GET requests are slightly limited due to maximum argument lengths). I'm calling it from a C# webapp which interrogates our Solarwinds NCMv6 database and then POSTs the various parameters. The webapp itself is fairly simple: just some database access code, a SQL query to return the most recent configuration for every device in the inventory, and a couple of Regexps to pull out ACLs and their names from a Cisco IOS/NXOS config which I've reproduced above. On our IIS installation, I simply changed the extension of the script to .plex and it executed happily.

There is a privacy policy in place for compliance with Google Analytics terms of service, which this site uses to optimise search engine placement by permitting periodical review of search terms associated with hits.