An edited, shorter version of this paper appeared with the title "The Power of Packet Filtering" in Windows NT Magazine, January 2000.
Firewalls to protect an organization's connection to the Internet or to protect extranets/intranets are commonplace today. Without a firewall of some sort, an organization's network is wide open to access by anyone connected to the same public network.
Packet filtering is about the most common method of building a Transmission Control Protocol/Internet Protocol (TCP/IP) firewall. Whether managed by some sort of GUI or command line interface, this scheme filters IP packets based upon a set of rules that can be defined at a router or other packet forwarding device, such as an NT server. The implementation of the packet filtering ruleset will depend upon the specific equipment and the vendor.
The first part of this article will define packet filtering, relate it specifically to various TCP/IP protocols, and provide some guidelines for filtering IP packets. The second part will discuss a specific packet filtering application using the Windows NT-based Routing and Remote Access Service.
Figure 1 shows the layers of the TCP/IP protocol stack relevant to packet filtering. Despite the name, the protocol stack obviously refers to much more than a single protocol pair and much more than a single protocol layer. The TCP/IP stack comprises four layers:
|
Application Layer |
HTTP FTP Telnet Finger DNS POP3/IMAP SMTP Gopher BGP Time/NTP Whois TACACS+ SSL |
DNS SNMP RIP RADIUS Archie Traceroute tftp |
Ping
|
Transport | Layer
| TCP
| UDP
| ICMP
| OSPF
Internet | Layer
| IP
| ARP
Network | Access Protocols
Ethernet/802.3 Token Ring (802.5) SNAP/802.2 X.25 FDDI ISDN | Frame Relay SMDS ATM Wireless (WAP, CPDP, 802.11) Fibre Channel DDS/DS0/T-carrier/E-carrier SONET DWDM PPP HDLC SLIP/CSLIP xDSL Cable Modem (DOCSIS)
| FIGURE 1. Abbreviated TCP/IP protocol stack. | ||||||||||||
Packet filtering is used to control the movement of IP packets based upon the contents of the packet. Packet filtering rules can be keyed to some combination of host address, protocol, type of application, direction of connection, and message type. To understand the operation of any packet filtering, the relationship between the protocol layers must first be understood.
For TCP/IP packet filtering, all packets have at least one thing in common -- specifically, all filtering starts with an IP packet. There are three fields of an IP packet that are critical for filtering purposes:
Packet filtering can be performed based on any of the fields listed above. It is relatively obvious how filtering can be done on an address basis; one can block, for example, all packets from a particular address or set of addresses, and/or can allow packets to enter and be routed to some set of addresses.
Of more interest is the PID field. There are many protocols for which data is carried directly in an IP packet, such as:
The Internet Assigned Numbers Authority (IANA) maintains a list of all protocol numbers on the Web at http://www.isi.edu/in-notes/iana/assignments/protocol-numbers.
It is important to know which protocols you need to filter at your site and which are supported by your packet filtering device. Some packet filters will only allow filtering based upon higher-layer protocols already known to the filter's software; others allow you to specify the PID, allowing the definition of new or unknown protocols.
Presuming that you are performing packet filtering based on a TCP- or UDP-based application, you need to be familiar with ports. Host-to-host communication using either TCP or UDP is uniquely identified on an IP network by the four parameters (source IP address, source port number, destination IP address, destination port number).
The port number identifies the application that is running over TCP or UDP. Port numbers in the range 0-1023 are called Well Known Ports. These port numbers are assigned to the server side of an application and, on most systems, can only be used by processes with a high level of privilege (such as root or administrator). Port numbers in the range 1024-49151 are called Registered Ports, and these are numbers that have been publicly defined as a convenience for the Internet community to avoid vendor conflicts. Server or client applications can use the port numbers in this range. The remaining port numbers, in the range 49152-65535, are called Dynamic and/or Private Ports and can be used freely by any client or server. Some sample port numbers, and the protocol(s) with which they are most commonly associated, are:
|
20 (TCP): File Transfer Protocol (FTP) data 21 (TCP): FTP control 23 (TCP): Telnet 25 (TCP): Simple Mail Transfer Protocol (SMTP) 37 (UDP): Time 43 (TCP): NICNAME/whois 53 (TCP/UDP): Domain Name System (DNS) 69 (UDP): Trivial FTP (TFTP) 79 (TCP): Finger 80 (TCP): Hypertext Transfer Protocol (HTTP) 110 (TCP): Post Office Protocol version 3 (POP3) 119 (TCP): Network News Transfer Protocol (NNTP) |
137 (TCP/UDP): NETBIOS Name Service 123 (UDP): Network Time Protocol (NTP) 138 (UDP): NETBIOS Datagram Service 139 (TCP): NETBIOS Session Service 143 (TCP): Internet Message Access Protocol (IMAP) 161 (UDP): Simple Network Management Protocol (SNMP) 162 (UDP): SNMP trap 179 (TCP): Border Gateway Protocol (BGP) 443 (TCP): Secure HTTP (HTTPS) 520 (UDP): Routing Information Protocol (RIP) 1080 (TCP): SOCKS 33434 (UDP): "Invalid" port used by traceroute |
By controlling the port numbers allowed through your packet filter, you can control which external applications and services your internal users can access, as well as which internal applications and services can be accessed by external users. The IANA maintains a list of TCP/UDP port numbers on the Web at http://www.isi.edu/in-notes/iana/assignments/port-numbers.
An additional factor to be considered when setting up packet filter rules for TCP is the "direction" of the connection. TCP hosts must establish a virtual connection before they can exchange data. This setup process uses a so-called three-way handshake because it requires the exchange of three TCP segments to synchronize the two hosts' sequence and acknowledge numbers. In general, the client initiates a connection to the server although there are some notable exceptions to this rule; while the FTP client initiates an FTP-control TCP connection with an FTP server, for example, it is the FTP server that initiates the FTP-data connection to the client.
FIGURE 2. Sample scenario using an NT server running RRAS between a user site and ISP. |
Figure 2 shows a sample scenario where an NT server is acting in the role of a router, forwarding packets between a user site and an Internet service provider (ISP). In this context, inbound refers to packets coming into the user network from the outside and outbound refers to packets leaving the user network for the outside.
When configuring the packet filter, you can restrict not just applications, then, but also the direction of the connection. Thus, you can ensure, for example, that internal users can establish TCP connections to servers on the outside but restrict incoming connections.
There are two philosophical design issues that should form the basis for your packet filtering rules and policies:
Using the protocol information presented so far, here are some basic guidelines for filtering IP packets and TCP/UDP applications:
Although an integral part of IP, ICMP is a stand-alone protocol and ICMP messages are filtered separately from IP packets. The role of ICMP is to notify an IP host of some error or other information. There are several attacks that utilize ICMP messages, including "The Ping of Death" (gigantic Ping messages that overflow buffers), SMURF (using Ping messages and the IP broadcast address to flood a victim's Internet access link), and ICMP Redirect attacks (sending bogus messages redirecting traffic away from a trusted site). All of the ICMP messages are useful (but not necessarily essential) for network operation, but nearly all of them can also be abused by an attacker. Some suggestions for ICMP message filtering are:
Be aware that ICMP defines message types and subtypes. The ICMP message type 3, for example, is Destination Unreachable. That message type has several subtypes specified by a code; code=0 is Network Unreachable, code=1 is Host Unreachable, and code=3 is Port Unreachable. Be sure that your packet filter can get down to the granularity that you require for your site's security policies. The IANA list of ICMP messages can be found at http://www.isi.edu/in-notes/iana/assignments/icmp-parameters.
There are several ways in which packet filtering can be implemented. One common approach is to use the packet filtering or access control list (ACL) capability of most routers. Windows NT servers can also do some rudimentary packet filtering as one of the advanced TCP/IP options and more sophisticated packet filtering if the Routing and Remote Access Service (RRAS) update is installed on the NT Server. RRAS has several features, including support for routing protocols such as RIPv2 for IP and OSPF, demand dial routing, server-to-server PPTP, and RADIUS client support. For our purposes, the packet filtering features of RRAS will be examined. Figure 2 showed one scenario where RRAS might be used. In this figure, an NT server acts essentially like a router, providing the interconnection between a user's site and an ISP. The NT server's packet forwarding capabilities allow it to act like a router; RRAS is employed for its packet filtering services to protect the site's connection to the Internet. In this scenario, one of the server's network interfaces connects to the Ethernet LAN (at 192.168.12.1) and the other network interface connects to some wide area network (WAN) access to the ISP (at 192.168.13.1) interfaces. (For reasons of security and privacy, actual IP network numbers are not shown in this diagram and have been replaced with RFC 1918 private IP addresses instead.)
FIGURE 3. Sample scenario using an NT server running RRAS between a user site and an ISP's on-premises router. |
Another deployment scenario for a RRAS-based packet filter might be in the case where the user has no access to the router connecting the site to the ISP (Figure 3). In some cases, a small business might be connected to the Internet via an ISP which also provides the router. The router configuration cannot be modified by the user because the ISP owns the router, hence the router's packet filtering capabilities go unused. In this case, an NT server running RRAS might be setup with two LAN interface cards and sit between the router and the user's LAN.
In either case, as shown in Figures 2 and 3, the user's site has its own Web (HTTP), e-mail (SMTP/POP3), and primary DNS server (for convenience, all are at 192.168.12.20). A secondary DNS server, at 204.70.25.234, is hosted by the ISP. The paragraphs below show the steps for setting up the following packet filter rules (a subset of the packet filtering guidelines above):
The following steps were used to create the packet filtering to implement the ruleset above, using the NT Server Routing and RAS Admin utility:
|
|
|
IP addresses spoofing is prevented by using specific source addresses or a range of local IP addresses, in all of the filters. By inference, any source addresses not explicitly allowed is blocked.
|
|
Packet filtering can be implemented in a router, packet forwarding server, or firewall. A router, such as those from Cisco, Bay Networks, and Ascend, has its own operating system with its own command line interface. One of the downsides often cited about packet filtering is that it is not only difficult to correctly create a rule set, but it the difficulty is exacerbated by the arcane syntax of the router. A packet-forwarding server, such as an NT Server running the Routing and Remote Access Service (RRAS), or a firewall, such as Checkpoint's Firewall-1, provide a GUI to configure the packet filtering rule set and this greatly simplifies the task. Routers, of course, have specialized hardware and software that are optimized for high-speed, real-time operations. And the cost of quality routers continues to drop so that a good router today costs less than a good server.
Another approach to protecting the local network is via a proxy server. Proxy servers do not filter packets, per se. When a user on the inside attempts to connect to a server on the outside, a connection is established to the proxy server which, in turn, makes the connection to the external server. A similar operation occurs when an external user connects to an internal server. Most proxy servers have a GUI for configuration and are most beneficial when used in concert with packet filtering.
Packet filtering is very powerful security tool. But knowledge of the TCP/IP protocol suite, and how the individual protocols work and interact, is a requirement to build good packet filter rulesets that will work. One of the best books on packet filtering is Building Internet Firewalls by D. Brent Chapman and Elizabeth D. Zwicky (O'Reilly & Associates).
About the Authors: Gary C. Kessler is a senior network security analyst at SymQuest Group (http://www.symquest.com), a network integration consulting company in South Burlington, VT. His e-mail addresses is kumquat@sover.net. Rik Dayvie is a technical services coordinator and Craig Martin is a member of the technical staff at Hill Associates (http://www.hill.com), a telecommunications training and education company in Colchester, VT. E-mail can be sent to them at r.dayvie@hill.com and c.martin@hill.com, respectively.