Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Is it possible to "record" (to a text file perhaps) netstat in real time in OSX? If so, how?

Hello, I am wanting be to be able to monitor the connections coming to (and from) my computer to see exactly what is going on. Kind of like a "Wireshark" deal... but with netstat instead! :D

I'd like to be able to append it to a text file as well. I would consider myself to be an amateur Unix user that is fairly comfortable with the *nix command line interface.

Anyways, any help would be greatly appreciated! Thanks!

2 Answers

Relevance
  • 7 years ago

    As inclusive says. Maybe with netstat -tu to just record network connections not unix sockets

    Personally, I record in pcap format with tcpdump, e.g

    tcpdump -w foo.cap -s 300 not arp

    which can then be re-filtered and analyzed with tcpdump, tethereal or wireshark or anything else that understands pcap. The "-s 300" limits the amount of data per packet - "-s 0" records everything (up to the maximum 1600 bytes, or more than than if you have jumbo frames), while the default is something like 64 - enough to get the headers but no content like HTTP URLs.

  • 7 years ago

    netstat -c | tee -a file

    You could also try opening two terminals and enter `netstat -c > file` into one and `tail -f file` into the other one.

Still have questions? Get your answers by asking now.