ACL Fundamentals
ACL Fundamentals
Overview
1
6/16/2013
Overview
2
6/16/2013
3
6/16/2013
4
6/16/2013
• Standard IP ACLs
– Can only filter on source IP addresses
• Extended IP ACLs
– Can filter on:
• Source IP address
• Destination IP address
• Protocol (TCP, UDP)
• Port Numbers (Telnet – 23, http – 80, etc.)
• and other parameters
5
6/16/2013
(Standard IP)
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
• Task:
– Permit only the host 172.16.30.2 from exiting the Sales
network.
– Deny all other hosts on the Sales network from leaving
the 172.16.30.0/24 network.
6
6/16/2013
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
(Standard IP)
Applying ACLs
• You can define ACLs without applying them.
• However, the ACLs will have no effect until they are applied to the router's
interface.
• It is a good practice to apply the Standard ACLs on the interface closest to the
destination of the traffic and Extended ACLs on the interface closest to the
source. (coming later)
Defining In, Out, Source, and Destination
• Out - Traffic that has already been routed by the router and is leaving the
interface
• In - Traffic that is arriving on the interface and which will be routed router.
7
6/16/2013
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
RouterB(config)# interface s 0
RouterB(config-if)# ip access-group 10 out
RouterB(config)# interface s 1
RouterB(config-if)# ip access-group 10 out
8
6/16/2013
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
Because of the implicit deny any, this has an adverse affect of also denying
packets from Administration from reaching Engineering, and denying packets from
Engineering from reaching Administration.
RouterB(config)#access-list 10 permit 172.16.30.2
Implicit “deny any” -do not need to add this, discussed later
RouterB(config)#access-list 10 deny 0.0.0.0 255.255.255.255
RouterB(config)# interface s 0
RouterB(config-if)# ip access-group 10 out
RouterB(config)# interface s 1
RouterB(config-if)# ip access-group 10 out
Learn by example!
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
Preferred, this access list will work to all existing and new interfaces on RouterB.
RouterB(config)#access-list 10 permit 172.16.30.2
Implicit “deny any” -do not need to add this, discussed later
RouterB(config)#access-list 10 deny 0.0.0.0 255.255.255.255
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
9
6/16/2013
Example 2
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
• Task:
– Permit only the hosts 172.16.30.2, 172.16.30.3,
172.16.30.4, 172.16.30.5 from exiting the Sales
network.
– Deny all other hosts on the Sales network from leaving
the 172.16.30.0/24 network.
Example 2
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
Once a condition is met, all other statements are ignored, so the implicit
deny any only applies to not-matched packets.
RouterB(config)#access-list 10 permit 172.16.30.2
RouterB(config)#access-list 10 permit 172.16.30.3
RouterB(config)#access-list 10 permit 172.16.30.4
RouterB(config)#access-list 10 permit 172.16.30.5
Implicit “deny any” -do not need to add this, discussed later
RouterB(config)#access-list 10 deny 0.0.0.0 255.255.255.255
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
10
6/16/2013
Example 2
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
RouterB(config)# interface e 0
RouterB(config-if)# no ip access-group 10 in
Example 3
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
• Task:
– Deny only the host 172.16.30.2 from exiting the Sales
network.
– Permit all other hosts on the Sales network to leave the
172.16.30.0/24 network.
• Keyword “any” can be used to represent all IP Addresses.
11
6/16/2013
Example 3
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
Order matters! What if these two statements were reversed? Does the
implicit deny any ever get a match? No, the permit any will cover all other
packets.
RouterB(config)#access-list 10 deny 172.16.30.2
RouterB(config)#access-list 10 permit any
Implicit “deny any” -do not need to add this, discussed later
RouterB(config)#access-list 10 deny 0.0.0.0 255.255.255.255
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
Example 3
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
Order matters! In this case all packets would be permitted, because all
packets would match the first access list statement. Once a condition is met,
all other statements are ignored. The second access list statement and the
implicit deny any would never be used. This would not do what we want.
RouterB(config)#access-list 10 permit any
RouterB(config)#access-list 10 deny 172.16.30.2
Implicit “deny any” -do not need to add this, discussed later
RouterB(config)#access-list 10 deny 0.0.0.0 255.255.255.255
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
12
6/16/2013
RouterB(config)# interface e 0
RouterB(config-if)# ip access-group 10 in
13
6/16/2013
14
6/16/2013
Wildcard Masks!
Wildcard Masks!
Test Condition
Test
Conditon
10101100.00010000.00000000.00000000
00000000.00000000.11111111.11111111
------------------------------------
A Match… Matching packets will look like this…
The packet
10101100.00010000.any value.any value
• Wildcard masking used to identify how to treat the corresponding IP address bits.
– 0 - “check the corresponding bit value.”
– 1 - “do not check (ignore) that corresponding bit value.”
• A zero in a bit position of the access list mask indicates that the corresponding
bit in the address must be checked and must match for condition to be true.
• A one in a bit position of the access list mask indicates the corresponding bit in
the address is not “interesting”, does not need to match, and can be ignored.
15
6/16/2013
Wildcard Masks!
Test Condition
Test
Conditon
10101100.00010000.00000000.00000000
00000000.00000000.11111111.11111111
------------------------------------
Must Match No Match Necessary
A Match… The packet
10101100.00010000.any value.any value
Resulting in the bits that must match or doesn’t matter.
Matching packets will look like this.
• Task:
– Want RouterA to permit entire sales network and just
the 172.16.50.2 station.
– Deny all other traffic from entering Administrative
network.
16
6/16/2013
17
6/16/2013
-----------------------------------------
172.16.50.2 10101100 . 00010000 . 00110010 . 00000010
The
packet(s)
RouterA(config)# interface e 0
RouterA(config-if)#ip access-group 11 out
18
6/16/2013
Remember that implicit deny any? It’s a good idea for beginners to include
the deny any statement just as a reminder.
RouterA(config)#access-list 11 permit 172.16.30.0 0.0.0.255
RouterA(config)#access-list 11 permit 172.16.50.2 0.0.0.0
RouterA(config)#access-list 11 deny 0.0.0.0 255.255.255.255
RouterA(config)# interface e 0
RouterA(config-if)#ip access-group 11 out
-----------------------------------------
0.0.0.0 00000000 . 00000000 . 00000000 . 00000000
The
0.0.0.1 00000000 . 00000000 . 00000000 . 00000001 packet(s)
... (through)
255.255.255.255 11111111 . 11111111 . 11111111 . 11111111
19
6/16/2013
“any” keyword
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
• Simply put, the any option substitutes 0.0.0.0 for the IP address and
255.255.255.255 for the wildcard mask.
• This option will match any address that it is compared against.
Previous example:
• Deny only the host 172.16.30.2 from exiting the Sales network.
• Permit all other hosts on the Sales network to leave the 172.16.30.0/24
network.
• Keyword “any” can be used to represent all IP Addresses.
20
6/16/2013
interface
Denied Sales Engineering
Administration
This will deny packets from 172.16.30.0/24 from reaching all devices in the
172.16.10.0/24 Administration LAN, except RouterA’s Ethernet 0 interface, of
172.16.10.1. The access list will need to be applied on Router A’s Serial 0
interface for it to be denied on RouterA’s Ethernet 0 interface. A better
soluton is to use an Extended Access list. (coming)
Practice
21
6/16/2013
Answers Explained
A. 172.16.0.0 0.0.255.255
RouterB(config)#access-list 10 permit 172.16.0.0 0.0.255.255
22
6/16/2013
Answers Explained
D. 172.16.32.0 255.255.240.0
RouterB(config)#access-list 10 permit 172.16.32.0 0.0.15.255
There is a relationship!
Bitwise-not on the Subnet Mask
D. 172.16.32.0 255.255.240.0
RouterB(config)#access-list 10 permit 172.16.32.0 0.0.15.255
23
6/16/2013
24
6/16/2013
“host” option
25
6/16/2013
26
6/16/2013
Must match
172.30.16.0 10101100 . 00011110 . 00010000 . 00000000
0.0.15.255 00000000 . 00000000 . 00001111 . 11111111
-----------------------------------------
172.30.16.0 10101100 . 00011110 . 00010000 . 00000000
172.30.16.1 10101100 . 00011110 . 00010000 . 00000001
through . . .
172.30.31.254 10101100 . 00011110 . 00011111 . 11111110
172.30.31.255 10101100 . 00011110 . 00011111 . 11111115
Any Value
172.30.16.0 10101100 . 00011110 . 00010000 . 00000000
0.0.15.255 00000000 . 00000000 . 00001111 . 11111111
-----------------------------------------
172.30.16.0 10101100 . 00011110 . 00010000 . 00000000
172.30.16.1 10101100 . 00011110 . 00010000 . 00000001
through . . .
172.30.31.254 10101100 . 00011110 . 00011111 . 11111110
172.30.31.255 10101100 . 00011110 . 00011111 . 11111115
27
6/16/2013
28
6/16/2013
29
6/16/2013
• Note: More than one interface can use the same access-
list.
30
6/16/2013
• With inbound Access Lists the IOS checks the packets before it is sent to the
Routing Table Process.
• With outbound Access Lists, the IOS checks the packets after it is sent to the
Routing Table Process, except destined for the router’s own interface.
– This is because the output interface is not known until the forwarding
decision is made.
Standard ACL
31
6/16/2013
• Extended ACLs are used more often than standard ACLs because they
provide a greater range of control.
• Extended ACLs check the source and destination packet addresses
as well as being able to check for protocols and port numbers.
• This gives greater flexibility to describe what the ACL will check.
• Packets can be permitted or denied access based on where the packet
originated and its destination as well as protocol type and port
addresses.
32
6/16/2013
33
6/16/2013
Example 1
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
172.16.10.2/24
Port 172.16.30.2/24 172.16.50.2/24
80
Task
• What if we wanted Router A to permit only the Engineering workstation
172.16.50.2 to be able to access the web server in Administrative
network with the IP address 172.16.10.2 and port address 80.
• All other traffic is denied.
Example 1
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
172.16.10.2/24
Port 172.16.30.2/24 172.16.50.2/24
80
RouterA(config)#inter e 0
RouterA(config-if)#ip access-group 110 out
34
6/16/2013
Example 2
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
172.16.10.2/24
Port 172.16.30.2/24 172.16.50.2/24
80
Task
• What if we wanted Router A to permit any workstation on the Sales
network be able to access the web server in Administrative network
with the IP address 172.16.10.2 and port address 80.
• All other traffic is denied.
Example 2
172.16.20.0/24 172.16.40.0/24
s0 s0 s1 s0
RouterA .1 .2 RouterB .1 .2 RouterC
.1 e0 .1 e0 .1 e0
172.16.10.2/24
Port 172.16.30.2/24 172.16.50.2/24
80
RouterA(config)#inter e 0
RouterA(config-if)#ip access-group 110 out
• When configuring access list statements, use the “?” to walk yourself
through the command!
35
6/16/2013
• With inbound Access Lists the IOS checks the packets before it is
sent to the Routing Table Process.
• With outbound Access Lists, the IOS checks the packets after it is
sent to the Routing Table Process.
– This is because the output interface is not known until the
forwarding decision is made.
36
6/16/2013
Named ACLs
Named ACLs
37
6/16/2013
Named ACLs
Named ACLs
38
6/16/2013
Placing ACLs
Source
10.0.0.0/8
Destination 172.16.0.0/16
Placing ACLs
Source
10.0.0.0/8
Destination 172.16.0.0/16
• If the ACLs are placed in the proper location, not only can traffic be
filtered, but it can make the whole network more efficient.
• If traffic is going to be filtered, the ACL should be placed where it has
the greatest impact on increasing efficiency.
39
6/16/2013
deny telnet
deny ftp
permit any Source
10.0.0.0/8
Destination 172.16.0.0/16
• Policy is to deny telnet or FTP Router A LAN to Router D LAN.
• All other traffic must be permitted.
• Several approaches can accomplish this policy.
• The recommended approach uses an extended ACL specifying both
source and destination addresses.
deny telnet
deny ftp
permit any Source
10.0.0.0/8
RouterA Destination 172.16.0.0/16
interface fastethernet 0/1
access-group 101 in
access-list 101 deny tcp any 172.16.0.0 0.0.255.255 eq telnet
access-list 101 deny tcp any 172.16.0.0 0.0.255.255 eq ftp
access-list 101 permit ip any any
• Place this extended ACL in Router A.
• Then, packets do not cross Router A's Ethernet, do not cross the serial
interfaces of Routers B and C, and do not enter Router D.
• Traffic with different source and destination addresses will still be permitted.
40
6/16/2013
deny telnet
deny ftp
permit any Source
10.0.0.0/8
RouterA Destination 172.16.0.0/16
interface fastethernet 0/1
access-group 101 in
access-list 101 deny tcp any 172.16.0.0 0.0.255.255 eq telnet
access-list 101 deny tcp any 172.16.0.0 0.0.255.255 eq ftp
access-list 101 permit ip any any
• If the permit ip any any is not used, then no traffic is permitted.
• Be sure to permit ip and not just tcp or all udp traffic will be denied.
deny 10.0.0.0
Source permit any
10.0.0.0/8
Destination 172.16.0.0/16
interface fastethernet 0/0
RouterD access-group 10 in
access-list 10 deny 10.0.0.0 0.255.255.255
access-list 10 permit any
41
6/16/2013
deny 10.0.0.0
Source permit any
10.0.0.0
Destination 172.16.0.0/16
interface fastethernet 0/0
RouterD access-group 10 in
access-list 10 deny 10.0.0.0 0.255.255.255
access-list 10 permit any
• Better to use extended access lists, and place them close to the
source, as this traffic will travel all the way to RouterD before being
denied.
Firewalls
42
6/16/2013
Firewalls
• ISPs use ACLs to deny RFC 1918 addresses into their networks as
these are non-routable Internet addresses.
• IP packets coming into your network should never have a source
addresses that belong to your network. (This should be applied on all
network entrance routers.)
• There are several other simple access lists which should be added to
network entrance routers.
• See Cisco IP Essentials White Paper for more information.
Rt1(config-line)#
43
6/16/2013
Rt1(config-line)#
44