Windows – Mac equivalent of `netstat -b -n`

command linemacoswindows

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)

Best Answer

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.

Related Question