Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl shows no output in tcpdump

Tags:

curl

tcpdump

I'm attempting to diagnose a network issue with tcpdump. I run the command

tcpdump -i eth0 -nS host nameless.host.io

When I issue either traceroute or ping commands to hit nameless.host.io I see information from tcpdump but when I use curl to retrieve content from the host

curl http://nameless.host.io/mycontent/data

the curl command returns the content I expect but I see no output from tcpdump. The host is definitely "external" so it should go out on the wires.

Why would tcpdump be silent on a successful curl command?

like image 721
Paul Joireman Avatar asked Mar 21 '17 13:03

Paul Joireman


People also ask

How do I display tcpdump output?

The "-r" option lets you read the output of a file. All you have to do is use the "-r" option with tcpdump command and specify the path of the file you want to read.

Does tcpdump capture outgoing traffic?

With the help of tcpdump and WinDump, you can easily capture outbound TCP packets on Linux and Windows.


2 Answers

i can think of 3 different ways this can happen -

1: too many packets too fast, the packets-to-print-buffer runs full, and the kernel "drops" the packets curl sends before tcpdump has a chance to print them to you. solution would be to increase the buffer space, eg by using --buffer-size=102400 (this would dedicated about 100MB of ram to the buffer, i'm not sure what the default size is, but i think it's in the range of 1-4MB)

2: you have multiple network "interfaces", and you're listening in on the wrong one. i'm not sure how to ask curl which interface it uses, but you can explicitly tell curl to download via a specific interface, by doing curl --interface eth0 URL - and on Linux & Mac & BSD, you can get a list of available interfaces by doing sudo ifconfig (and i think the windows equivalent is in the control panel somewhere, but idk)

3: tcpdump's default user can't read the packets of the user curl is running as for some reason... turns out tcpdump by default drops into its own user called tcpdump when capturing, you could try to capture from the same user that curl runs as by using -Z curluser , or force tcpdump to capture as root by doing -Z root

like image 141
hanshenrik Avatar answered Sep 21 '22 17:09

hanshenrik


Do you select the right interface ? (ethX,wlanX....)

Try : tcpdump -s 0 -i [interface] host nameless.host.io and tcp port http

like image 33
GoA Oz Avatar answered Sep 19 '22 17:09

GoA Oz