Stateful packet inspection (SPF), or stateful inspection for short, enhances the packet filter approach by checking additional information about the connection state. In addition to the static table with the permitted ports and address ranges, this technology maintains a dynamic table containing information about the status of the individual connections. This dynamic table initially allows all vulnerable ports to be blocked; only when an approved connection (defined by source and destination address) requests it will a port be opened. The act of opening ports is always initiated from the protected network towards the unprotected network, i.e. generally speaking from the LAN to the WAN (Internet). Data packets that are not associated with a valid connection in the state table are automatically dropped.
In addition, stateful inspection can see from the connection establishment whether additional channels are being negotiated for the data exchange. Protocols such as FTP (for data transfer), T.120, H.225 and H.245 for Netmeeting or IP telephony), PPTP (for VPN tunnels) or IRC (for chat) establishing a connection from the LAN to the Internet using a particular source port indicate whether they are negotiating additional ports with the remote site. Stateful inspection enters these additional ports into the connection list, of course restricting them to the corresponding source and destination addresses.
Let's take another look at the example of an FTP download. When starting the FTP session, the client establishes a connection from the source port '4321' to the destination port '21' at the server. Provided that the FTP protocol is allowed from local computers to the outside, stateful inspection permits this initial connection to be established. The firewall enters the source and destination addresses along with the corresponding ports into the dynamic table. At the same time, the stateful inspection can inspect the control information sent to port 21 of the server. These control signals show that the client is requesting a connection from the server port 20 to the client port 4322. The firewall enters these values into the dynamic table because the client is requesting the connection into the LAN. The server can then send the data to the client as desired.