Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there an equivalent tool/shell command for Mac (preferably integrated with the OS) that has the functionality of the Windows command-line netstat -b -n? (displays active network connections, with the application that created them and source/dest IP+Port)

share|improve this question
    
OS X has a netstat command that shows all of this. It's called netstat too. –  skub Jan 21 '12 at 4:54

3 Answers 3

up vote 3 down vote accepted

OS X has a netstat command, but it doesn't display information about the programs associated with the network connections. If you want to see that, you need to use lsof instead. Note that it must be run as root (i.e. with sudo) in order to see other users' programs:

sudo lsof -i

lsof also has many options for controlling what's displayed:

sudo lsof -i tcp -nP   # show TCP unly (no UDP), and don't translate IP addrs and ports numbers to names
sudo lsof -i 6tcp -stcp:listen   # show only IPv6 TCP ports in the listen state
sudo lsof -i @10.11.12.13   # show only connections to/from 10.11.12.13

...see the man page for more.

share|improve this answer

As already been pointed out, netstat is also available on Mac OS X as a command line tool.

If you prefer a GUI tool integrated with the OS, then you can use network utility located here: /Applications/Utilities/Network\ Utility.app

Besides netstat, it allows easy access to other network utilities as well. A good overview on the network utility can be found in the article "How to use Network Utility".

share|improve this answer

lsof lists open files, so if a process is on last-ack say, they wont be listed

netstat will not give pids on osx

utility does not work as suggested

so no answers are correct

there is no way as far as i can see to duplicate the functioning of cports on the mac

all other answers are misleading

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.