Ania Katzenelson Asked: 2016-08-24 22:53:20 +0800 CST2016-08-24 22:53:20 +0800 CST 2016-08-24 22:53:20 +0800 CST tcpdump capture new connections only 772 I am using tcpdump to capture traffic from specific IP address. Is there the possibility to capture new connections only, meaning TCP streams that start with SYN packet? tcpdump tcp syn 2 Answers Voted pstrozniak 2016-08-24T22:57:42+08:002016-08-24T22:57:42+08:00 To capture only TCP SYN packets: # tcpdump -i <interface> "tcp[tcpflags] & (tcp-syn) != 0" JamesL 2020-01-25T13:21:54+08:002020-01-25T13:21:54+08:00 The following will capture both TCP-SYN and SYN-ACK packets. tcpdump -i <interface> "tcp[tcpflags] & (tcp-syn) !=0" The following will only capture TCP-SYN packets. tcpdump -i <interface> "tcp[tcpflags] & (tcp-syn) !=0 and tcp[tcpflags] & (tcp-ack) =0" The reason is, SYN-ACK packets include both the SYN and ACK flags. The first filter only looked for the presence of a SYN flag. If you want to filter on inbound only, add the -Q in option. tcpdump -i <interface> -Q in "tcp[tcpflags] & (tcp-syn) !=0 and tcp[tcpflags] & (tcp-ack) =0"
To capture only TCP SYN packets:
The following will capture both TCP-SYN and SYN-ACK packets.
The following will only capture TCP-SYN packets.
The reason is, SYN-ACK packets include both the SYN and ACK flags. The first filter only looked for the presence of a SYN flag.
If you want to filter on inbound only, add the -Q in option.