Why does this capture filter not capture my traffic?
I capture HTTP traffic and build Request/Response pairs.
I am using dumpcap and tshark.
I have a client (python script) that sends HTTP GET to one of 4 HTTP servers.
The client gets 200 OK as a response.
The client sends a 'special' HTTP request header having the name 'X-KINNERET'.
I have one version of BPF where I can "see" my client requests.
Below:
sudo dumpcap -i eno2 -f '(tcp && ((port 50003 && host 10.36.101.27) || (port 54017 && host 10.36.101.27) || (port 50003 && host 10.36.101.28) || (port 54017 && host 10.36.101.28)))' -B 100 -w - | tshark -r - -Y http -T json -e ip.dst -e tcp.dstport -e tcp.stream -e frame.time_epoch -e http.request -e http.request.method -e http.request.version -e http.request.full_uri -e http.request.uri -e http.request.line -e http.file_data -e http.response -e http.response.version -e http.response.code -e http.response.line | grep X-KINNERET
I have another version of BPF where I can NOT see my client requests.
Below:
sudo dumpcap -i eno2 -f '(tcp && ((src port 50003 && src host 10.36.101.27) || (dst port 50003 && dst host 10.36.101.27) || (src port 54017 && src host 10.36.101.27) || (dst port 54017 && dst host 10.36.101.27) || (src port 50003 && src host 10.36.101.28) || (dst port 50003 && dst host 10.36.101.28) || (src port 54017 && src host 10.36.101.28) || (dst port 54017 && dst host 10.36.101.28)))' -B 100 -w - | tshark -r - -Y http -T json -e ip.dst -e tcp.dstport -e tcp.stream -e frame.time_epoch -e http.request -e http.request.method -e http.request.version -e http.request.full_uri -e http.request.uri -e http.request.line -e http.file_data -e http.response -e http.response.version -e http.response.code -e http.response.line | grep X-KINNERET
The second BPF does capture traffic but not the traffic coming from my python script.
Any idea why the second 'strict' BPF does not work?
Thanks
Presumably ports 50003 and 54017 are the destination ports that the HTTP servers are listening on, have you also fixed the source ports your python script is using for the requests or are those using ephemeral ports? If the latter, then your second filter is likely excluding the requests due to the source ports.
Your second filter also restricts the source IP's to .27 & .28, does your request generating script run on a host with both IP's or is that a typo?
Hi Graham
Thanks for your answer.
Below is the list of my "HTTP Servers"
My python client uses ephemeral ports - it does not set the port. The problematic BPF (at least as I currently understand it..) is making sure that one of the "sides" that are using the socket will be one of the servers in the list. Therefore I have
(src port P && src host H) || (dst port P && dst host H) // where P and H are symbol represents an entry in the 4 servers list above.
Can you please try and explain why this filter exclude my client?
Thanks
Avishay
Could you comment with the output of the following two commands :
(the added
-d
will dump the BPF code so we can ...(more)See the answer below (I was not able to use the comment)
(more)"Non Strict Filter"
(more)