Configuring Numbered Extended IPv4 ACLs
For more precise traffic-filtering control, use extended IPv4 ACLs, numbered 100 to 199 and 2000 to 2699 or named, which check for the source and destination IPv4 address. In addition, at the end of the extended ACL statement, you can specify the protocol and optional TCP or User Datagram Protocol (UDP) application to filter more precisely. Figure 6-16 illustrates the IP header fields that can be examined with an extended access list.
Figure 6-16 Extended IPv4 Access Lists
An Example from a TCP/IP Packet
Figure 6-16 Extended IPv4 Access Lists
An Example from a TCP/IP Packet
To specify an application, you can configure either the port number or the name of a well-known application. Table 6-5 shows an abbreviated list of some well-known port numbers of the various TCP applications.
|
Well-Known Port Number (Decimal) |
IP Protocol |
|
20 (TCP) |
FTP data |
|
21 (TCP) |
FTP control |
|
23 (TCP) |
Telnet |
|
25 (TCP) |
Simple Mail Transfer Protocol (SMTP) |
|
53 (TCP/UDP) |
Domain Name System (DNS) |
|
69 (UDP) |
TFTP |
|
80 (TCP) |
HTTP |
http://www.iani.org/assignments/port-numbers provides a more comprehensive list of well-known port numbers.
http://www.iani.org/assignments/port-numbers provides a more comprehensive list of well-known port numbers.
To configure numbered extended IPv4 ACLs on a Cisco router, create an extended IPv4 ACL and activate that ACL on an interface. Use the access-list command to create an entry to express a condition statement in a complex filter. The full command follows:
access-list access-list-number {permit | deny} protocol source source-wildcard [operator port] destination destination-wildcard [operator port] [established] [log]
Table 6-6 explains the syntax of the command.
|
access-list Command Parameters |
Description |
|
access-list-number |
Identifies the list using a number in the ranges of 100-199 or 20002699. |
|
permit 1 deny |
Indicates whether this entry allows or blocks the specified address. |
|
protocol |
IP, TCP, UDP, ICMP, GRE1, or IGRP2. |
|
source and destination |
Identifies source and destination IP addresses. |
|
source-wildcard and destination-wildcard |
Wildcard mask; 0s indicate positions that must match, and 1s indicate "don't care" positions. |
|
operator \port\app_name] |
The operator can be lt (less than), gt (greater than), eq (equal to), or neq (not equal to). The port number referenced can be either the source port or the destination port, depending on where in the ACL the port number is configured. As an alternative to the port number, well-known application names can be used, such as Telnet, FTP, and SMTP. |
|
established |
For inbound TCP only. Allows TCP traffic to pass if the packet is a response to an outbound-initiated session. This type of traffic has the acknowledgement (ACK) bits set. (See the Extended ACL with the Established Parameter example.) |
|
log |
Sends a logging message to the console. |
1 GRE = generic routing encapsulation
2 IGRP = Interior Gateway Routing Protocol
1 GRE = generic routing encapsulation
2 IGRP = Interior Gateway Routing Protocol
The syntax of the access-list command that is presented here is representative of the TCP protocol form. Not all parameters and options are given. For the complete syntax of all forms of the command, refer to the appropriate Cisco IOS Software documentation available at Cisco.com.
Extended ACL with the established Parameter
In Example 6-6, the established parameter of the extended ACL allows responses to traffic that originate from the mail host, 128.88.1.2, to return inbound on the serial 0 interface. A match occurs if the TCP datagram has the ACK or reset (RST) bits set, which indicates that the packet belongs to an existing connection. Without the established parameter in the ACL statement, the mail host could only receive SMTP traffic but not send it.
Example 6-6 Access List Permitting Responses to an Originating Mail Host
|
access-list 102 permit tcp access-list 102 permit tcp |
any any |
host host |
128.8 128.8 |
8.1.2 8.1.2 |
established eq smtp |
|
interface serial 0 ip access-group 102 in |
The ip access-group command links an existing extended ACL to an interface. Only one ACL per protocol, per direction, and per interface is allowed.
|
ip access-group Command Parameters |
Description |
|
access-list-number |
Indicates the number of the ACL that is to be linked to an interface |
|
in I out |
Selects whether the ACL is applied as an input or output filter; out is the default |
The following list shows the steps that are required to configure and apply an extended ACL on a router:
Step 1
Step 2
Define an extended IPv4 ACL. Use the access-list global configuration command.
RouterX(config)# access-list 101 deny tcp 172.16.4.0 0.0.0.255 172.16.3.0 0.0.0.255 eq 21
Use the show access-lists command to display the contents of the ACL. In the example, access-list 101 denies TCP traffic from source 172.16.4.0, using the wildcard 0.0.0.255, to destination 172.16.3.0, using the wildcard 0.0.0.255 on port 21 (FTP control port).
Select a desired interface to be configured. Use the interface global configuration command.
RouterX(config)# interface ethernet 0.
After the interface command is entered, the CLI prompt changes from (config)# to (config-if)#.
Step 3 Link the extended IPv4 ACL to an interface. Use the ip access-group interface configuration command: RouterX(config-if)# ip access-group 101 in
Use the show ip interfaces command to verify that an IP ACL is applied to the interface.
Numbered Extended IP ACL: Deny FTP from Subnets
For the network in Figure 6-17, you want to create a list to prevent FTP traffic that originates from the subnet 172.16.4.0/24, going to the 172.16.3.0/24 subnet, from traveling out Ethernet interface E0.
Figure 6-17 Extended ACL Denying FTP from One Subnet to Another
The configuration in Example 6-7 provides a solution for this example.
Example 6-7 Access List Preventing FTP Traffic from Specific Subnets
|
RouterX(config)# access |
list |
101 |
deny tcp 172.16.4 |
0 0.0.0.255 |
172 |
16.3 |
0 0.0.0.255 |
eq |
21 |
|
RouterX(config)# access |
list |
101 |
deny tcp 172.16.4 |
0 0.0.0.255 |
172 |
16.3 |
0 0.0.0.255 |
eq |
20 |
|
RouterX(config)# access |
list |
101 |
permit ip any any |
||||||
|
(implicit deny all) |
|||||||||
(access-list 101 deny ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255) RouterX(config)# interface ethernet 0 RouterX(config-if)# ip access-group 101 out
(access-list 101 deny ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255) RouterX(config)# interface ethernet 0 RouterX(config-if)# ip access-group 101 out
172.16.3.0
|
access-list Command Parameters |
Description |
|
101 |
ACL number; indicates an extended IPv4 ACL |
|
deny |
Indicates that traffic that matches the selected parameters is not forwarded |
|
tcp |
|
|
172.16.4.0 0.0.0.255 |
Source IP address and mask; the first three octets must match but not the last octet |
|
172.16.3.0 0.0.0.255 |
Destination IP address and mask; the first three octets must match but not the last octet |
|
eq 21 |
Destination port; specifies the well-known port number for FTP control |
|
eq 20 |
Destination port; specifies the well-known port number for FTP data |
|
out |
Links ACL 101 to interface E0 as an output filter |
The deny statements deny FTP traffic from subnet 172.16.4.0 to subnet 172.16.3.0. The permit statement allows all other IP traffic out interface E0.
Numbered Extended ACL: Deny Only Telnet from Subnet
For the network in Figure 6-18, you want to create a list to prevent Telnet traffic that originates from the subnet 172.16.4.0/24 from traveling out Ethernet interface E0.
Figure 6-18 Extended ACL Denying Telnet from a Given Subnet
172.16.3.0
Continue reading here: Configuring Named ACLs
Was this article helpful?