Here you can find the latest stable version of tcpdump and libpcap, as well as current development versions, a complete documentation, and information about how to report bugs or contribute patches.
This tcpdump release fixes an out-of-bounds write vulnerability (CVE-2023-1801) present in the previous release (4.99.3) in the SMB printer, which is not compiled by default. It also makes various minor improvements. This release requires libpcap 1.10.0 or later to pass all test cases.
If you want to contribute, please subscribe to the tcpdump-workers mailing list. It's a good idea to discuss bugfixes and new feature additions in advance, because the changes may have bigger implications than you think and your patch may not get accepted.
tcpdump and libpcap are under a 3-clause BSD license. While the current authors have no objection to converting to a 2-clause BSD license, the number of contributors that would need to agree makes this change unpracticable.
A powerful and versatile tool that includes many options and filters, tcpdump can be used in a variety of cases. Since it's a command line tool, it is ideal to run in remote servers or devices for which a GUI is not available, to collect data that can be analyzed later. It can also be launched in the background or as a scheduled job using tools like cron.
Tcpdump continues to capture packets until it receives an interrupt signal. You can interrupt capturing by pressing Ctrl+C. As you can see in this example, tcpdump captured more than 9,000 packets. In this case, since I am connected to this server using ssh, tcpdump captured all these packets. To limit the number of packets captured and stop tcpdump, use the -c (for count) option:
By default, tcpdump resolves IP addresses and ports into names, as shown in the previous example. When troubleshooting network issues, it is often easier to use the IP addresses and port numbers; disable name resolution by using the option -n and port resolution with -nn:
As shown above, the capture output now displays the IP addresses and port numbers. This also prevents tcpdump from issuing DNS lookups, which helps to lower network traffic while troubleshooting network issues.
Tcpdump is capable of capturing and decoding many different protocols, such as TCP, UDP, ICMP, and many more. While we can't cover all of them here, to help you get started, let's explore the TCP packet. You can find more details about the different protocol formats in tcpdump's manual pages. A typical TCP packet captured by tcpdump looks like this:
As mentioned above, tcpdump can capture too many packets, some of which are not even related to the issue you're troubleshooting. For example, if you're troubleshooting a connectivity issue with a web server you're not interested in the SSH traffic, so removing the SSH packets from the output makes it easier to work on the real issue.
One of tcpdump's most powerful features is its ability to filter the captured packets using a variety of parameters, such as source and destination IP addresses, ports, protocols, etc. Let's look at some of the most common ones.
Back in the tcpdump capture, notice that tcpdump captures and displays only the ICMP-related packets. In this case, tcpdump is not displaying name resolution packets that were generated when resolving the name opensource.com:
Notice that tcpdumps captured packets with source IP address 192.168.122.98 for multiple services such as name resolution (port 53) and HTTP (port 80). The response packets are not displayed since their source IP is different.
In the previous examples, we're checking only the packets' headers for information such as source, destinations, ports, etc. Sometimes this is all we need to troubleshoot network connectivity issues. Sometimes, however, we need to inspect the content of the packet to ensure that the message we're sending contains what we need or that we received the expected response. To see the packet content, tcpdump provides two additional flags: -X to print content in hex, and ASCII or -A to print the content in ASCII.
Another useful feature provided by tcpdump is the ability to save the capture to a file so you can analyze the results later. This allows you to capture packets in batch mode overnight, for example, and verify the results in the morning. It also helps when there are too many packets to analyze since real-time capture can occur too fast.
One benefit of Wireshark is that it can read .pcap files captured by tcpdump. You can use tcpdump to capture packets in a remote machine that does not have a GUI and analyze the result file with Wireshark, but that is a topic for another day.
It depends, but usually tcpdump will show you all packets while SecureXL is enabled. If I had to put a percentage probability on it I'd say 75%. Factors that will determine the outcome are:
1) Packets being handled in the Accelerated Path (SXL) vs. Medium (PXL)/Firewall (F2F) paths. All traffic in the PXL/F2F paths will show up in tcpdump, and considering the typical blades enabled on firewalls today most traffic tends to be handled in PXL. Traffic to and from the gateway itself (i.e. SSH management, logging, policy loads) and the ICMP protocol are *never* accelerated by SecureXL, will always go F2F, and will appear in tcpdump and fw monitor 100%.
This is due to how SecureXL works with accelerated packets on the outbound side, so if in your tcpdump capture you see NAT oddities or can't seem to see all packets of a connection, don't beat your head against the wall unnecessarily trying to figure out why you can't see everything.
3) If there is hardware acceleration (i.e. 23000 SAM/ADP card) involved, chances are good that tcpdump will not see that traffic at all. I'm curious to see how this will be handled (or not) on the upcoming Falcon accelerator card.
If you are experiencing problems seeing all traffic with tcpdump (or have a limited time window to execute the tcpdump and want to maximize the chances of getting a complete capture), it is vastly preferable to selectively disable SecureXL for the IP address(es) you want to capture as described here:
As described in the SK, this is easily accomplished by editing the table.def file on the SMS and pushing policy to the gateway ahead of time. Once this is done tcpdump (and fw monitor) will give you a complete capture as all traffic matching the defined exclusion will go F2F. If the IP address(es) cannot be known ahead of time, it is also possible to define a SecureXL exclusion based on destination port number. Generally it is not a good idea to completely disable SecureXL via fwaccel off for this purpose, especially on a gateway with more than 8 cores as it may cause severe performance issues.
One last warning: if you are capturing packets that are fragmented, tcpdump will show the individual fragments in their original state, while fw monitor will only show the packets after they have been virtually reassembled for inspection and not how they actually appear on the wire. Fragmented packets always go F2F unless a SAM/ADP card is present.
Simple! All you need to do is type tcpdump.
Running tcpdump without any switches will just spit out all packets going in and out of the router.
The full list of command line switches for tcpdump can be found on the man page here.
Many applications also rely on local connections, typically on the loopback interface, and may be affected by the local firewall (iptables or the Windows Firewall Service, for example). Using tcpdump, you can see if the packets are immediately rejected, which is likely to be the firewall service, or if it completes a three-way handshake before closing the connection. In almost all cases, if a three-way handshakes is observed, the application has received the connection.
Next, we need to generate a filter to look at traffic. The tcpdump man page provides a lengthy list of filter components. One of the most common components is srcdsthost , which filters for packets from, to, or bi-directionally for the specified IP or network. Others are port and , like icmp or gre. We can combine individual components with standard logical operators like and, or, and not: filter for non-ssh traffic to/from 10.0.0.200 with host 10.0.0.0.200 and not port 22.
Practical tcpdump examples to lift your network troubleshooting and security testing game. Commands and tips to not only use tcpdump but master ways to know your network.
Without the option to force line (-l) buffered (or packet buffered -C) mode you will not always get the expected response when piping the tcpdump output to another command such as grep. By using this option the output is sent immediately to the piped command giving an immediate response when troubleshooting.
This example is straight out of the tcpdump man page. By selecting on the tcp-syn and tcp-fin packets we can show each established TCP conversation with timestamps but without the data. As with many filters this allows the amount of noise to be reduced in order to focus in on the information that you care about.
Parsing and analysis of full application streams such as HTTP is much easier to perform with Wireshark (or tshark) rather than tcpdump. It is often more practical to capture traffic on a remote system using tcpdump with the write file option. Then copy the pcap to the local workstation for analysis with Wireshark.
Other than manually moving the file from the remote system to the local workstation it is possible to feed the capture to Wireshark over the SSH connection in real time. This tip is a favorite, pipe the raw tcpdump output right into wireshark on your local machine. Don't forget the not port 22 so you are not capturing your SSH traffic.
df19127ead