Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need a command, or something that runs as a cron job, that logs what IPs my machine is communicating with, what ports, and what process did it.

share|improve this question
    
Running something as a cron job means you will miss many connections. I'd suggest learning the ropes of auditd. –  Deer Hunter May 9 '13 at 4:51

2 Answers 2

up vote 2 down vote accepted

Use Socket Stat:

ss -p

You might want to explore ss manpage for some more options, like -r to resolve ip addresses to domain name:

ss -pr

Another good tool is netstat, but I found ss command line invocation to be simpler with respect to the result you want.

share|improve this answer
    
ss is a linux specific utility. netstat is more widely available (but the options differ depending on OS). –  jordanm May 8 '13 at 22:39
2  
Right! Anyway, the OP was looking for a Linux solution, so ss is fine. –  Stefano Sanfilippo May 8 '13 at 23:10

There are many tools and ways to do this but this is probably what you're looking for:

http://www.tcpdump.org/

share|improve this answer

Your Answer

 
discard

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.