Вы находитесь на странице: 1из 11

White Paper:

Fw Monitor
A troubleshooting tool
May 2005
White Paper: fw Monitoring May2005

Table of Contents

Introduction............................................................................................................................................................................................................. 2
The OSI Model – a troubleshooting framework........................................................................................................................................... 2
Running fw monitor ............................................................................................................................................................................................. 2
Anatomy of a filter expression ................................................................................................................................................................. 3
Output of fw monitor .................................................................................................................................................................................. 3
The 4 Capture Points.................................................................................................................................................................................... 3
Limitations of fw monitor ......................................................................................................................................................................... 4
Commonly Used Options ..................................................................................................................................................................................... 4
Write output to file [-o <file>] .................................................................................................................................................................. 4
Limit the packet length [-l len]................................................................................................................................................................. 4
Capture masks [-m mask] .......................................................................................................................................................................... 5
Example Scenarios................................................................................................................................................................................................. 5
Capturing all traffic to or from a host .................................................................................................................................................... 5
Capturing VRRP traffic ................................................................................................................................................................................. 5
Creating complex filters.............................................................................................................................................................................. 5
Alternate versions of the Complex Filter............................................................................................................................................... 6
Troubleshooting a NATed Connection ................................................................................................................................................... 6
Advanced filter expressions: using lists ................................................................................................................................................ 7
References....................................................................................................................................................................................................... 7

1
White Paper: Push to Talk Technology March 2005

each layer performs a subset of the functions needed for


Introduction two devices to communicate. The protocols are then
fw monitor is a useful packet capture tool provided by linked together to enable the communication.
Check Point as a part of VPN-1/FireWall-1. It allows a
network troubleshooter to capture packets as they pass The Physical Layer handles the bits on the wire. A Physical
through the VPN-1/FireWall-1 Enforcement Module. In Layer Protocol specification will define how bits are
order to use the tool, however, the prospective network encoded into electrical signals and how devices should
troubleshooter must first understand the fundamentals interpret bit patterns as bytes. For example, the IEEE
of computer networking. We discuss the basics of using 802.3 specification for Ethernet mandates that 100BASE-
the fw monitor utility, including some common optional TX Ethernet will use a 4B5B binary encoding mechanism
parameters, which can be very useful. Finally, we end to convert bits into electrical signals.
with a series of examples illustrated network
troubleshooting. A Data Link Protocol provides the specifications that allow
a network interface card (NIC) to communicate with
The OSI Model – a troubleshooting another NIC. For example, Ethernet defines the MAC
address and how to craft a data frame so that a NIC can
framework transmit the frame and that a receiving NIC can receive
As all Students of Networking know, it is mandatory that and interpret the frame of data.
we discuss the OSI Model before diving into a packet
capture tool. The Transport Layer provides for program-to-program
communication. For example, my client may have a web
session and a terminal session with the same server host.
At the network layer, the communications look the same
– packets between my client IP address and the server IP
Address. At the Transport Layer, however, we see TCP Port
numbers, which identify which packets belong to which
sessions.

The remaining layers, Session, Presentation and


Application, are less important in the TCP/IP suite of
protocols and, therefore, are less important to most
network troubleshooting. It should be pointed out that
the Application Layer is not the application itself, for
example a web server. Rather, the Application Layer
Protocol is often like an API for the client and server
applications. The web client sets an HTTP GET request,
and the web server returns data, and the HTTP Protocol
specifies how the GET request is formatted and how the
data should be returned.

Following the data as it passes through the TCP Stack of


the web server illustrates the second key OSI Model
Figure 1: The OSI Model and its mapping to TCP/IP protocols
concept of Encapsulation. Each layer takes the output of
the previous layer and encapsulates it, wrapping the data
in its header. At the other end, the recipient simply peels
The OSI Model provides the framework for our
off each layer like an onion and passes the data up to the
troubleshooting efforts. It is a theoretical model, and
next Layer.
while it is very useful in organizing our thinking about
data communications, it does not map one-to-one with
current popular protocols. The important thing the model
shows us is that network communications are modular –

2
White Paper: Push to Talk Technology March 2005

Figure 2: Encapsulation of the data by each layer of the Network Stack

As shown in Figure 2, the web server has a chunk of data, troubleshooter should start at the bottom and work
for example, the text of a web page. The application her way up. Check that the wire is plugged in or that
wraps the data in an HTTP data unit and passes to the TCP the WEP keys have been typed correctly. Check that the
layer, which resides in the kernel. The TCP layer processes host is able to find the MAC address needed to transmit
the entire HTTP data unit by segmenting the data into a frame. Check that the router is forwarding the packet
chunks and placing a TCP header on the front of each out of the correct NIC to reach the end host. Check that
chunk. TCP then hands its data to the IP layer, which does the correct port number is being used. Network
the same thing, treating the entire TCP data unit as one Troubleshooting by protocol analysis is rarely that
data payload, appending an IP header and passing the hard, but it can be time consuming to discern each
entire thing to the Ethernet driver. The Ethernet driver communication session from the individual packets
appends its header and, in the case of Ethernet, a trailing and frames.
checksum and passes the frame to the physical NIC for
transmission on the wire. Running fw monitor
The fw monitor command is relatively straightforward to
Thus the frame on the wire contains each protocol
use. One can just run the command by itself
header in succession and then finally the chunk of data
being transferred from server to client. We can capture firewall[admin]# fw monitor
this frame with a packet capture tool and see what the
headers and data are. In order to understand what we and the utility will flood you with data. To end the
are looking at, we need to know the protocol which is capture, simple press Ctrl-C (i.e., the Control key and the c
being used. A Protocol is just a set of rules that both key simultaneously).
sides understand. For example, because of the IP Protocol
Specification, hosts know which 4 bytes of the 20 byte IP In most situations, there is simply too much data to
header is the destination address. analyze. fw monitor uses short VPN-1/FireWall-1 Inspect
scripts to determine which data to capture and present.
Basically, network troubleshooting reduces to mapping, Inspect scripts use an offset notation to match specific
at each layer, where the data unit is going to and where bytes within a packet. Luckily, Check Point has defined a
is it coming from. That information is then compared number of keywords to represent these offset notation
against expectations until the problem is identified. Our entries. These definitions can be found in the various
expectations are built from our knowledge of how the $FWDIR/lib/*.def files, especially $FWDIR/lib/tcpip.def.
protocols are specified to work and from our One example is the src keyword, which is equivalent to
understanding of the network topology at each OSI layer. the ip_src keyword which is equivalent to the offset [12,
b]. The src keyword matches the given parameter against
Most network connectivity issues can be resolved by the IP Source address in the packets. For example, to
analyzing the behavior of network communications at
match all packets coming from a particular host, we could
the first 4 layers of connectivity. The network
use

2
White Paper: fw Monitoring May2005

firewall[admin]# fw monitor –e “accept the length as Check Point sees the datagram. This length
src=10.10.10.51;” comes from Check Point’s Virtual Defragmentation Engine
and can be different from the length as reported in the IP
and the output would show every packet received by Header for the packet. The line ends with a decode of the
firewall with an IP Source address of 10.10.10.51. IP header: Source IP to Destination IP, decode of the IP
Protocol field, display of the IP Length field and of the ID
Anatomy of a filter expression field of the IP Header.
In the above command, the –e tells the fw monitor utility
to expect a filter expression. The filter expression must be The 4 Capture Points
isolated from the shell by quotes so that the entire As mentioned above, the default fw monitor output
expression is passed to the fw monitor utility. includes four lines for each packet passed by the firewall.
The four lines correspond to the four main capture points
The first part of the quoted expression tells fw monitor to provided by the Enforcement Module:
accept packets that match the following expression. The
expression src=10.10.10.51 describes only packets with a pre-inbound inspection ( i )
Source IP Address of 10.10.10.51. No packets coming
from any other source nor packets destined for post-inbound inspection ( I )
10.10.10.51 will be included in the output. Finally, the pre-outbound inspection ( o )
ending semicolon ( ; ) is critical. Frequently, when filter
post-outbound inspection ( O ).
expressions are suggested using a sans-serif or
proportional font, the semicolon becomes invisible next The inclusion of the Capture Point in the decode is,
to the quotation mark. More than one engineer has spent perhaps, the most import feature of fw monitor for the
hours trying different filter expressions in vain only to network troubleshooter. VPN-1/FireWall-1, by default,
finally realize that the semicolon was missing. compares network traffic against its policy and state
tables both when the packet is received (inbound) as well
as immediately
before the packet is
transmitted
(outbound). The four
primary capture
points correspond to
points immediately
before and after the
VPN-1/FireWall-1
inspection points. If
we see that a packet
was captured only
prior to an
inspection but not
after and inspection,
we can conclude
Figure 3: Default output of fw monitor command that some aspect of
firewall policy is the
cause of our network problem.
Output of fw monitor
By default, fw monitor provides 4 lines of decode for each For example, if a packet only generates one line of output
packet passed by VPN-1/FireWall-1. If the packet is marked with the pre-inbound inspection ( i ) identifier,
carrying a TCP, UDP or ICMP data unit, as in Figure 3, fw we can be confident that the VPN-1/FireWall-1 policy is
monitor will display a second line decoding that protocol. causing the packet to be dropped. The VPN-1/FireWall-1
The first element of the decode is the interface on which policy and log viewer should be used to figure out which
the packet is either being received or being sent. Next, we rule is causing the problem.
have the Capture Point identifier ( i, I, o, O) followed by

3
White Paper: Push to Talk Technology March 2005

Another example would be if only lines for inbound data as well as more advanced filtering options, thereby
inspection ( i, I ) are shown but outbound inspection ( o, making it easier to figure out what is going on.
O ) are missing. This would indicate that the packet is
either terminating at the firewall itself or that routing Instead of outputting decoded packets to the terminal,
has been misconfigured and the routing engine of fw monitor writes the raw packet binary data to a file.
thedevice is blackholing the packet. There are several limitations to this output, however:

If the expected packet doesn’t even produce any inbound 1. Because fw monitor never sees the Data Link Layer
inspection decode lines, this means either that the filter data, it cannot capture the Data Link Layer data. fw
expression is incorrect or that the packet is never making monitor, however, uses the bytes reserved for Data
it to the Enforcement Module for inspection. Other tools Link Layer header information to encode the
would then be needed to see what is going on outside Interface and Capture Point information presented in
the firewall device. the normal fw monitor output. To quote Check
Points “How to use fw monitor 10-Jul-2003”

Limitations of fw monitor Alfred Köbler (Alfred.Koebler@icon.de ) wrote an


addition to Ethereal which enables Ethereal to
Unlike many packet capture utilities, fw monitor cannot
show Data Link Layer or lower protocol information. The display not MAC addresses but the fw monitor
NIC strips the Data Link Layer information before handing information. This addition is part of the standard
the packet to the VPN-1/FireWall-1 module. On the up
Ethereal distribution since version 0.9.9. It can be
side, fw monitor can, as we have seen, show the packet
activated using
at different inbound and outbound capture points along
Edit/Preferences/Protocols/Ethernet/Interpret as
the way.
FireWall-1 monitor
Using the OSI model as our troubleshooting guide, it
would be wise to first verify that the network traffic is
2. Packet capture files can become quite large. Care
flowing correctly at the Data Link Layer before using fw
must be taken to limit the traffic captured by
monitor to analyze traffic at the Network Layer. Tools
carefully using filter expressions. The Limit the packet
like tcpdump, snoop and 3rd party protocol analyzers can
length [-l len] option can also help reduce this
be used to check the transmission of data at the Data Link
problem.
Layer. Many 3rd party analyzers can even detect Physical
Layer problems. 3. Unless the Limit the packet length option is used,
packet capture files will contain potentially sensitive
Misconfigured Proxy ARP is an example of a problem that
data from the network connections being captured.
fw monitor simply cannot solve. If hosts are not even
Care must be taken with the resulting file
transmitting the frames to the NIC of the firewall, VPN-
1/FireWall-1 will never inspect the packet and fw monitor 4. In order for the packet capture to be useful, it must
will never provide and lines of decode to analyze. first be transferred off the firewall.
Tcpdump, however, can capture traffic not transmitted
directly to the firewall’s NIC and can display the incorrect It is good practice to chose a file name that ends in a
hardware addressing. “.pcap” or “.dmp” extension. This makes it easier for
Ethereal on a Windows platform to open the file directly.
Commonly Used Options
fw-1[admin]# fw monitor –o monitor.pcap –e “accept
The following options extend the usefulness of fw src=10.10.10.51;”
monitor.

Write output to file [-o <file>] Limit the packet length [-l len]
The –o <file> option is very useful for getting the data out The Limit the packet length option can help overcome
of the terminal window and into a full featured protocol some of the problems with using the Write output to file
analyzer like Ethereal. Ethereal can decode a far greater option. Usually the network troubleshooter is only
array of Transport, Session, Presentation and Application interested in the header data. The actual data being
layer protocols. It provides various views of the packet transferred can cause the packet capture file to swell to

4
White Paper: fw Monitoring May2005

enormous size and frequently contains sensitive scope of this tutorial, but relevant facts regarding the
information. By carefully choosing a packet length (len) protocols will be provided.
value to capture, both of the problems can be reduced.
Capturing all traffic to or from a host
The question then is, what len value to use? The The simple filter example used previously will only
parameter defines the number of bytes of the captured capture traffic from the host 10.10.10.51. If you need to
frame which should be included in the packet capture file. see all traffic to or from a particular host use:
The IP header is usually contained within the first 38
bytes of the frame, and the TCP header is usually within –e “accept src=10.10.10.51 or dst=10.10.10.51;”
the first 58 bytes. NetBios related protocols, such as
Microsoft’s SMB implementation, and RPC (Remote Notice the use of the Logical Operator or. We want to see
Procedure Call) related protocols, such as Sun’s NFS traffic in both directions, i.e., packets either destined for
(Network File System) protocol, can frequently require 10.10.10.51 or coming from 10.10.10.51. A common
more that 200 bytes of frame data. Experience and trial mistake is to use the logical operator and. Such a
and error become the usually ways a network construction, however, results in no packets being
troubleshooter decides which len values to use. matched, because ordinarily there are no network
packets from a particular IP address destined for that
As a starting point, try a value of 300 if capturing same IP address .
Microsoft or Sun implemented protocols. Try a value of
128 if capturing standard IETF defined protocols like
HTTP, as in the following example: Capturing all traffic of a specific service
To capture all traffic related to a specific service, the
fw-1[admin]# fw monitor –o monitor.pcap –l 128 –e correct identifier must be know. For example, to capture
“accept src=10.10.10.51;” all web traffic, which uses TCP Port 80, the following filter
can be used:
Capture masks [-m mask]
This option is particularly useful when analyzing standard -e “accept sport=80 or dport=80;”
fw monitor output on the command line. Frequently we
only care if the packet made it through the firewall, and Likewise, DNS traffic uses UDP Port 53, so to capture all
the post-inbound inspection ( I ) and the pre-outbound DNS traffic we can use:
inspection ( o ) decode lines just make the output harder
-e “accept sport=53 or dport=53;”
to read.
Capturing VRRP traffic
The mask parameter in its simplest form is just a
sequence of the the iIoO characters used to identify the The VRRP protocol header immediately follows the IP
desired capture points. Therefore, if we only want to header. The IP Protocol value of 112 has been assigned
capture output from the pre-inbound inspection ( i ) and to VRRP. To filter on an IP Protocol value, the ip_p macro
post-outbound inspection ( O ) Capture Points, we could must be used. The following expression will capture all
modify our fw monitor command like so: VRRP traffic:

firewall[admin]# fw monitor –e “accept -e “accept ip_p = 112;”


src=10.10.10.51;” –m iO
Creating complex filters
In addition to the logical operator or, fw monitor
provides several additional logical operators:
Example Scenarios
In this section, we will describe a number of scenarios, or Logical OR
the filter expression needed to capture the relevant traffic “,” and Both the comma and the keyword and work as a
and an explanation of the analysis. Troubleshooting of Logical AND
network problems requires an understanding both of the
network topology as well as of the protocols being used. xor Logical XOR (not commonly used)
A full discussion of the relevant protocols is outside the Not Logical NOT (not commonly used)

5
White Paper: Push to Talk Technology March 2005

In addition to the relational operator =, fw monitor -e “accept src=10.10.10.51 and dst=192.168.0.101 and
provides several additional logical operators: sport=80 ; \

= or Both the equals sign and the keyword is accept src=192.168.0.101 and dst=10.10.10.51 and
is work as the relational operator EQUAL dport=80) ;”
!= or Both the exclamation point/equals sign combination As the logical operator “and” can be replaced with a
is and the keyword is not work as the relational comma ( , ), original statement can be written even more
not operator NOT EQUAL confusingly as:
< Relational operator LESS THAN
fw1[admin]# fw monitor –e
> Relational operator GREATER THAN “((src=10.10.10.51,dst=192.168.0.101) \
<= Relational operator LESS THAN OR EQUAL TO or(src=192.168.0.101,dst=10.10.10.51)),(sport=80 or
dport=80) ;”
>= Relational operator GREATER THAN OR EQUAL
TO
Troubleshooting a NATed Connection
Let’s take the scenario where we need to examine all
web traffic between two hosts. To limit the traffic to only If one of the hosts is NATed at the firewall, the above
the two hosts in question we need an expression that complex filter expression will not capture the packet at
captures only traffic between the two hosts all four inspection capture points. After the NAT takes
place, the packet will no longer match the expression and
(src=10.10.10.51 and dst=192.168.0.101) or will no longer be captured by fw monitor.
(src=192.168.0.101 and dst=10.10.10.51)
In the case of Static NAT, a solution is obvious: just add
Now we must add an expression to capture only web the static NAT address to the expression. If the server
traffic between the two hosts (note, we are using the 10.10.10.51 is NATed to 172.16.10.51, then the filter
backslash character ( \ ) to escape a newline character expression becomes:
inserted to make the line readable)
fw1[admin]# fw monitor –e “(((src=10.10.10.51 or
((src=10.10.10.51 and src=172.16.10.51) \
dst=192.168.0.101)or(src=192.168.0.101 and
dst=10.10.10.51)) \ and dst=192.168.0.101) or (src=192.168.0.101 and
(dst=172.16.10.51 or \
and (sport=80 or dport=80)
dst=10.10.10.51))) and (sport=80 or dport=80)”
In a UNIX csh environment, the final command to capture
only port 80 web traffic between hosts 10.10.10.51 and As the example’s inscrutability demonstrates, just adding
192.168.0.101 would be: additional parameters may not be the best way to
proceed. When dealing with Hide NAT, the potential for
fw1[admin]# fw monitor –e “((src=10.10.10.51 and capturing unrelated packets becomes greater as many
dst=192.168.0.101) \ or(src=192.168.0.101 and hosts are translated to the Hide NAT address.
dst=10.10.10.51)) and (sport=80 or dport=80) ;”
Perhaps we don’t need to see the missing packet,
The importance of using parentheses in complex filters because the existence of the other packets implies its
cannot be overestimated. existence. In that case, the statement remains the same
as presented in the Complex Filter example.

Alternate versions of the Complex Filter Perhaps we can limit the packet capture sufficiently by
only filtering on the remote host IP address. For example,
Check Point’s Inspect scripting language is very versatile.
if our client is the only local client connecting to the
One example would be to use multiple accept statements
remote server, we can filter on the remote server IP
in a single filter expression. The same expression to
address or remote server IP address and TCP Port
capture all port 80 web traffic between hosts 10.10.10.51
numbers and only capture the desired communications,
and 192.168.0.101 can be written as:

6
White Paper: fw Monitoring May2005

including NATed traffic. In this case, we can actually References


simplify the filter expression: Check Point, “How to use fw monitor”, Jul 10, 2003.
Available from the Next Generation Utilities page
fw1[admin]# fw monitor –e “(src=10.10.10.51 or (“http://www.checkpoint.com/techsupport/downloadsng
dst=10.10.10.51) and \ /utilities.html”).
(sport=80 or dport=80)”

In truly complicated situations, such as where many hosts


and many servers are all using the same Application Layer
protocol to exchange data, the use of multiple accept
statements, as illustrated in the section “Alternative
versions of the complex filter”, can become a necessity.

Advanced filter expressions: using lists


Check Point provides a list feature that allows both for
the definition of specific hosts as well as the definition of
address ranges in filter expressions. A list is first defined,
and then that list can be used by name in later IP address
matching.

For example, say we need to find out if any address in a


particular subnet is accessing a commonly used server.
We could define a list that includes the subnet by using
the ‘<‘ and ‘>‘ to define a range of addresses:

fw1[admin]# fw monitor –e “[troubleNet] = {


<192.168.10.0, 192.168.10.255> } ; \

accept (src in troubleNet and dst=10.10.10.51) ;”

We can also define multiple hosts or multiple networks in


a list definition:
–e “[badHosts] = { 192.168.10.53, 192.168.21.18,
192.168.101.186 } ; \

accept (src in badHosts and dst=10.10.10.51) ;”

Saving output to a text file


Rather then using the Write output to file [-o <file>] to
capture raw packet data, simple shell redirection can be
used to capture the default fw monitor output to a file.
On a UNIX type system, simply use the redirection
operator > like so:

fw1[admin]# fw monitor –e “accept src=10.10.10.51;” >


monoutput.txt

and the file monoutput.txt will be created with the


standard output of the command.

7
About Nokia
Nokia is the world leader in mobile communications, driving the growth and sustainability of the broader
mobility industry. Nokia is dedicated to enhancing people's lives and productivity by providing easy-to-use
and secure products like mobile phones, and solutions for imaging, games, media, mobile network
operators and businesses. Nokia is a broadly held company with listings on five major exchanges.

For more information, please visit http://www.nokia.com/forbusiness

Americas
Nokia
313 Fairchild Drive, Mountain View, CA 94043
Tel: 1 877 997 9199
Email: mobile.business.americas@nokia.com
Europe, Middle East and Africa
Nokia
Nokia House, Summit Avenue
Southwood, Hampshire, GU14 ONG, UK
Tel UK: +44 161 601 8908
Tel France: +33 170 708 166
Email: mobile.business.emea@nokia.com
Asia Pacific
Nokia
438B Alexandra Road
#07-00 Alexandra Technopark, Singapore 119968
Tel: +65 6588 3364
Email: mobile.business.apac@nokia.com
www.nokia.com

Copyright © 2005 Nokia. All rights reserved. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. Other trademarks mentioned are the
property of their respective owners. Nokia operates a policy of continuous development. Therefore we reserve the right to make changes and improvements to any of
the products described in this document without prior notice. Under no circumstances shall Nokia be responsible for any loss of data or income or any direct, special,
incidental, consequential or indirect damages howsoever caused.

Вам также может понравиться