Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to log all network traffic on a Mac OS X server (like tcpdump does), but including the ID of the process that is responsible. Using lsof only gives me the current connections, not the past ones.

Is there a way to do this?

Regards, Jochen

share|improve this question

I recently had this problem too. One approach you can potentially take is to use both tcpdump and nettop in parallel (each, side by side, in their own terminal shells), and visually observe as the network traffic manifests.

For example, my firewall recently caught suspicious looking network traffic coming out of my Mac's Ethernet, on a private subnet which I did not recognize and on a port (TCP 7000) which looked unusual. In one terminal shell I ran:

$ sudo tcpdump port 7000

and in the other terminal shell I ran:

$ sudo nettop -m tcp

When the network traffic showed up via tcpdump, it nearly instantly was also was added to the nettop output, which indicated it was Apple's AirPlay helper daemon running with process ID (PID) 87 in this example:


This may not necessarily be practical for observing all situations where you're trying to catch something on your network which looks anomalous but as a starting point may be worth trying vs writing a probably more complex DTrace script.

share|improve this answer

Sadly, the best way to do this (tcpsnoop, which uses DTrace to do exactly what you describe) does not work on the Mac OS X implementation of dtrace. You'd need some kind of application firewall (Little Snitch for example) but that's more of a desktop / single user thing than something you want running on your server.

This seems like an odd requirement actually, are you trying to make an intrusion detection system, or just figure out what is causing network access?

share|improve this answer
Just trying to see what's causing weird network traffic on my box. Regards, Jochen – Jochen Feb 22 '11 at 18:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.