Home > Articles

Packet Filtering

This chapter is from the book

Tracking Rejected Traffic

When creating Cisco router access lists, one of the greatest downfalls of the log keyword is that it only records matches to the rule in question. Therefore, if the rule is a permit rule, you lose the profoundly important information about which packets are being denied. To track the traffic that is being filtered by an implicit deny, add a "deny any" ACL with the log keyword (as seen in the following example) to the bottom of the list in question. Functionally, the deny any log command does the same thing as the assumed implicit deny, but it facilitates the logging of denied traffic. One good application of this concept is to track abnormal traffic that is being filtered by the implicit deny at the end of an egress filter access list. Using this method allows a means to track all outbound traffic that has a source address other than that of your network. This is a great way to keep a handle on any strange things that might be trying to sneak out of your network! Here is a simple example of how you would tell the router to log blocked traffic:

access-list 11 deny any log

Filtering by Port and Destination Address: The Cisco Extended ACL

Another powerful use of packet-filtering technology involves filtering on packet header information and port numbers. These examples can be applied in the form of specific "conduits" that allow one system to access another (extranets), allow access to a specific public access system (web or DNS server), or allow a specific type of traffic into the network (ICMP packet-too-big unreachables). This functionality is enabled on a Cisco router using the extended access list.

The Cisco Extended ACL

The Cisco extended ACL offers additional features that allow more control of network traffic flow. Instead of only being able to filter on source address, we have the additional flexibility of destination address filtering, filtering based on protocol type, filtering on specific layer 4 port number information, flags, and more. With this additional granularity, the effectiveness of the Cisco router as a packet filter is greatly increased, making it viable for many security concerns.

The extended access list syntax is as follows:

access-list number 100-199 or 2000-2699 permit|deny protocol source
source-mask source-port destination destination-mask
destination port log|log-input options

You should recognize the first entries in the syntax from the standard access list, up to the protocol keyword. This is where you would specify the protocol you are interested in filtering. Possible selections are IP, TCP, UDP, and ICMP. Because TCP, UDP, and ICMP are all forms of IP-based traffic, when you use IP as the protocol on an access list, it permits or denies any of the other three traffic types. If we had used an extended access list to substitute for one of the standard access lists from the previous section, IP would have been the appropriate choice because it would have blocked all IP traffic types (UDP, TCP, and ICMP).

Remember the importance of rule order. Each incoming packet is checked by each access list in order from top to bottom. When a packet matches the criteria in any one of the access lists, an action is performed. If it is a permit filter, the packet is forwarded; if it is a deny filter, the packet is dropped. No rules test the packet beyond the rule that the packet matched. Use the following code to allow a particular packet in (let's say that its IP address is 205.205.205.1) if it is TCP but to deny it entry if it uses any other IP protocol:

access-list 111 deny ip host 205.205.205.1 any
access-list 111 permit tcp host 205.205.205.1 any

The first rule would test true for a TCP packet of address 205.205.205.1. Because it is a "deny" rule, the packet would be dropped. The packet would never get to be tested by the second rule. If the two rules were reversed in order, with the TCP rule first, the filter would work correctly.

In the extended access list's syntax, the source address and mask should look familiar; the destination address and mask follow the same format, and simply mean "where it is going" instead of "where it is from." The keyword any can be used to represent the numerical range 0.0.0.0–255.255.255.255, or all addresses.

This is the first time you see ports listed as part of an access list. As mentioned previously, ports are an important part of TCP/IP and the access lists. The source port or destination port entry can specify the type of traffic you want to allow or disallow. When specifying a port number or name, you must also include an operator, such as eq (meaning equal to this port number), gt (for any port above this number), lt (for any port less than this number), or my favorite range (to list an entire contiguous range of port numbers; use the syntax range port1 port2, where port1 is the first port in the range and port2 is the last).

Extended access lists are configured and applied just like standard access lists, including the association of an access group to an interface. Many options can be added to the end of the access list, such as log (as mentioned in the standard access list) or log-input (which also displays the input interface and source MAC address), flags to check for, and the established keyword.

"Friendly Net" Revisited

As mentioned previously, allowing access to a given IP address is not a favored practice. The main reason for this is lack of control and the dangers of spoofing. Using a standard ACL to allow access is a problem because the only thing we have control over is which IP address (or range) can access the entire inside network. This means that not only can the host or range of hosts specified access any station on the inside, but it also can do so on any port number. This is not good. Extended access lists can at least help tighten up that control. We can specify the destination host (or range) to which the host can connect, as well as the port on which they can communicate. This way, we can allow an outside trusted host to access our web server (only) on port 80 (only). Take a look at this example:

access-list 111 permit tcp host 100.100.100.1 gt 1023 host
200.200.200.2 eq 80 log

This example assumes that the trusted host is at address 100.100.100.1 and our target web server is at address 200.200.200.2. We only allow traffic from the trusted host on ephemeral ports, and only to port 80 on our web server. We add the log keyword to track traffic that is passing this rule.

This is not secure. All this guarantees is that we have control over those specified items, helping to lessen the ability of outsiders to exploit our defense. This ACL can be subverted in other ways.

Only allowing port 80 traffic doesn't ensure that only web traffic will transpire from the outside host to our web server. As a matter of fact, if a flaw exists to be exploited in our web server, and an attacker can get a Telnet program or other backdoor running on our web server on port 80, the server might as well be wide open. If this system is on a private network and not on a separate screened subnet, we are just a few leaps away from being fully compromised, especially if the web server has a trust relationship with any other mission-critical servers on our network.

Be sure to tightly harden the system if you elect to control access to its resources solely through the use of packet filters, without further authentication. If possible, run a multiple interface router (or packet-filtering device) or multiple levels of packet-filtering devices where you can structure a separate subnet for public access systems.

Filtering TCP and UDP Ports and ICMP Types

Another handy function of the extended access list is the filtering of certain types of traffic. You can control the types of traffic that leave your network, in effect enforcing your security policy. You can allow or disallow certain types of traffic that enter your network. Denying traffic to a list of popular Trojan program ports or to ports that programs use that conflict with your Internet usage or security policies (IRC, Kazaa, instant messaging programs, and so on) can also be an extra layer of defense. As stated previously, it makes more sense to only allow what you need. A more common use of port filtering is allowing traffic types that can enter or leave your network, like the example in the previous section. For a list of mission-critical ports that any environment should consider defending, see Appendix A of the SANS Top 20 Vulnerabilities, available at http://www.sans.org/top20.

Another use for this type of filtering is to allow or disallow certain informative ICMP messages entrance to your network. ICMP is one of the most exploited of the protocols. It is being used for reconnaissance, denial of service attacks (such as smurf), and more. It is recommended that you block incoming echo requests (ping and Windows traceroute), block any outgoing echo replies, and block time exceeded, for maximum security. All the ICMP traffic types can be blocked with extended ACLs. The use of any ICMP blocking filters could affect network traffic control.

ICMP doesn't work like the other protocols. Instead of having port numbers, it uses type and code identifiers. It is basically set up to send error messages for protocols that can't (such as UDP and IP) and to send informational messages (such as router error messages telling that a host is unreachable). ICMP is used by popular end-to-end troubleshooting utilities such as ping and traceroute. ICMP can be controlled by using Cisco access lists with special ICMP keywords or ICMP type numbers, instead of port numbers such as TCP and UDP access lists.

To block ICMP echo requests (ICMP type 8), we could use a line in an extended access list such as this:

router(config)#access-list 111 deny icmp any any echo-request

The main difference between this access list and others we have looked at is the keyword at the end of the line. This keyword represents the ICMP type and code for echo requests. It means, "deny any ICMP traffic from anywhere to anywhere with the type and code set to echo-request." This filter would be applied on the external router interface to the Internet. Other ICMP traffic types can be filtered in the same way using their type-of-service keywords.

A better way to handle the ICMP blocking would be to allow only the types of traffic that you want and then deny the rest. For example, one important ICMP packet type to allow in is the packet-too-big ICMP unreachable messages (type 3, code 4). This is because without this message, you could have major communications issues. What if a host can't receive a packet because it is too large for the router to handle and the router isn't allowed to return information to the host telling it that the packet is too large? How will the sender ever find out what is wrong and successfully communicate with the host? Luckily, in this example, Cisco has an ICMP keyword for the packet-too-big message. This keyword could be applied as follows, permitting the packet-too-big messages, but denying all other ICMP messages:

router(config)#access-list 111 permit icmp any any packet-too-big
router(config)#access-list 111 deny icmp any any

The filter would be applied as usual with an ip access-group 111 in command.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020