问题原文
原帖链接 · Ania Katzenelson · CC BY-SA 4.0
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?
社区高分解答
原帖链接 · JamesL · CC BY-SA 4.0
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"
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
