What you need to know about Cisco IOS access-list filtering
Let’s face it, if you don’t use Cisco IOS access lists (ACL) every day, they can be very painful to use. Why are ACLs so painful? Besides just being difficult to use, the penalty for mistake is huge. In one swift swoop, you could incorrectly permit malicious attackers onto your network or incorrectly deny all valid users from your network. Either way, the consequences could be devastating to your company and to your career. So how do you prevent this from happening? If you follow these guidelines, you will be “feeling good again” about your Cisco ACLs.
Know what an ACL can and cannot do
In the simplest of terms, a Cisco IOS ACL is used to define traffic. Once that traffic is defined, some action can then be taken on that traffic.
Commonly, an ACL is associated with the filtering of IP packets (Network Layer 3 of the OSI Model) as they pass through a router. In other words, it is used to permit or deny traffic through a router. However, if you just define the ACL only and don’t apply it to an interface using the access-group command, nothing happens.
While ACLs can be used for many functions like QoS, route filtering, and allowing access to the router, in this article, we will focus on using ACLs for filtering traffic in and out of the router.
Know the syntax of ACLs
To configure an ACL you need to include some basic information about which packets to permit or deny.
The general syntax for a standard access list is:
access-list {list number} permit | deny | [source address} [source mask]
Note that the standard ACL can only permit or deny traffic based on the source of the traffic.
The general syntax of a TCP extended access list is:
access-list access-list-number [dynamic dynamic-name [timeout minutes]] {deny | permit} tcp source source-wildcard [operator [port]] destination destination-wildcard [operator [port]] [established] [precedence precedence] [tos tos] [log | log-input] [time-range time-range-name] [fragments]
You should also know that extended ACL can filter IP traffic, TCP, UDP, ICMP, and other types of traffic. The syntax above is to filter TCP traffic.
Know that ACLs use wildcard masks
Cisco IOS ACLs use wildcard masks. These wildcard masks are required anytime you enter an IP address in your ACL. The only way NOT to enter an IP address (thus, using a wildcard mask) is to enter a keyword like “any” or use the keyword “host” before the absolute IP address of a host on the network.
Wildcard masks are the binary reverse of a subnet mask. Thus, to calculate a wildcard mask, you take the subnet mask of a network address or IP address, convert it to binary, turn all the 1s into 0s and the 0s into 1s, and convert it back to decimal. Sounds complicated, but it really isn’t. If the subnet mask is masked at the 8-bit subnet boundaries, then a 0 will turn into a 255 and a 255 will turn into a 0. Here are a few examples:
- SN 255.0.0.0 = wildcard 0.255.255.255
- SN 255.255.255.0 = wildcard 0.0.0.255
- SN 255.255.128.0 = wildcard 0.0.127.255
- SN 255.255.255.224 = 0.0.0.31
Do NOT use a subnet mask in a wildcard mask on a Cisco IOS router or switch, or you will end up with unintended results. (On the other hand, if you are configuring an ACL on a Cisco PIX, use regular subnet masks, not wildcard masks).
Know how to create an ACL and apply it to an interface
For example, here’s how a sample configuration might look for access list 1:
Router(config)# access-list 1 permit 172.16.30.0 0.0.0.255
Router(config-if)# interface e0/0
Router(config-if)# ip access-group 1 out
The ip access-group command is used to apply an ACL to an interface and specify the direction that it applies.
The commands above permit any traffic coming from IP network 172.16.30.0 going OUT the router’s Ethernet 0/0 interface.
Know the implicit deny
Let me ask you this: What is allowed through the ACL above? Answer: Only the traffic from the 172.16.30.0 /24 network. Why is that? That is because at the end of every ACL, whether you see it or not, ALL TRAFFIC IS IMPLICITLY DENIED.
So, what traffic is allowed through the ACL below?
Router(config)# access-list 1 deny 172.16.30.0 0.0.0.255
That’s right - NO TRAFFIC is allowed because certain traffic is explicitly denied and ALL OTHER TRAFFIC IS DENIED by the implicit deny.
How do you see the traffic being denied? You can enter your own explicit deny with the log keyword, like this:
Router(config)# access-list 1 permit 172.16.30.0 0.0.0.255
Router(config)# access-list 1 deny any log
Know that ACLs use top-down processing
Cisco IOS ACLs use top-down processing. This means that when a condition in the ACL is met, all processing is stopped. Thus, if there is a permit for network 1.1.1.0 in the fifth line of the ACL but it is denied in the third line of the ACL, then that traffic is denied.
Know the three Ps of ACLs
Remember, you can only apply ONE ACL:
- Per Interface
- Per Protocol
- Per Direction
As most of us are applying IP ACLs, the protocol doesn’t matter that much, but the important thing to know is that you can apply only ONE ACL on each interface in each direction. In other words, you can apply only one INBOUND and one OUTBOUND ACL per interface.
Know how to verify which ACLs are applied and which are configured
Showing what ACLs are created and what ACLs are applied is easy if you know just a few commands. These commands are:
- show access-lists
- show ip interface
- show running-config
Know that there are many methods and types of ACLs
The Cisco IOS supports IP Standard and Extended ACLs in both named and numbered versions. Additionally, there are reflexive, dynamic, and lock-and-key access lists, among many others.
Know how ACLs can be used in the real world
While you may understand the concept of ACLs and how to configure them, it is important to know how to use them in the real world.
Here are a few business applications for ACLs:
1. Basic packet filtering for security: Filter traffic from a host, a network, a protocol, or port.
2. Packet filtering for bandwidth control: Say that a streaming audio or video application was using network bandwidth, and it was on a certain port number. With an ACL, you could discard those video and audio packets to prevent overutilization of bandwidth.
3. Other functions with ACLs: Route filtering, QoS, controlling access to the router, etc.
Know where to find more resources to learn ACLs
There is a lot to know about ACLs, and we can’t cover it all in this short format. To learn more about ACLs, here are some links to other articles and videos I have created on this topic.
- TechRepublic.com: Use Advanced Parameters on Your Cisco IOS ACLs
- TechRepublic.com: Cisco IOS Access Lists - 10 Things You Should Know
- HappyRouter.com: Free Video - Hardening Your Router with Cisco IOS ACLs
- Petri.co.il: How to Edit Cisco IOS ACLs Using Line Numbers
Conclusion
ACLs are the least understood feature that new Cisco administrators and CCNA candidates struggle with. I hope you find this information about Cisco IOS access lists helpful, and you keep it handy to “cure those ACL pains” whenever they come up.
David Davis has worked in the IT industry for 15+ years and holds several certifications, including CCIE, CCNA, CCNP, MCSE, CISSP, VCP. He has authored hundreds of articles and numerous IT training videos. Today, David is the Director of Infrastructure at Train Signal.com. Train Signal, Inc. is the global leader in video training for IT Professionals and end users. Read his full bio and profile.
article source : techrepublic.com
No comments:
Post a Comment