TCPDUMP

On Linux, to capture data on a port and write to output.pcap, run

sudo tcpdump  -i any -v 'port 1514' -w output.pcap

To capture traffic on a server (192.168.11.153) where the client (1921.68.99.74) is accessing TCP-443 on the server.

tcpdump -i eth1 -n '(src 192.168.99.74 and dst 192.168.11.153 and dst port 443) or (src 192.168.11.153 and dst 192.168.99.74 and src port 443)'
tcpdump -i eth1 -n '(src 192.168.99.74 and dst 192.168.11.153 and dst port 443) or (src 192.168.11.153 and dst 192.168.99.74 and src port 443)'

Tcpdump filters allow you to capture specific types of network traffic based on various criteria, making it easier to analyze and troubleshoot network issues. You can filter by protocol (TCP, UDP, ICMP, etc.), IP address (source or destination), port number (source or destination), MAC address, and more. Advanced filters can also combine these criteria using logical operators like and, or, and not.

Basic Filters:

Advanced Filters (Combining Criteria):

Example Usages: Captures all TCP traffic on the eth0 interface destined for or originating from port 80

tcpdump -i eth0 tcp port 80

Captures all traffic related to the host 192.168.1.100 on any interface.

 tcpdump -i any host 192.168.1.100

Captures all traffic on the eth0 interface with the specified MAC address as the source.

 tcpdump -i eth0 ether src 00:11:22:33:44:55

Important Notes: