Watch All Open Network Connections in Mac OS X with Open_Ports
You can watch all open network connections for both incoming and outgoing transfers using a free command line utility called open_ports.sh. Open_Ports is much more useful than using lsof to list open internet connectionsbecause it provides extensive network information in a very easy to read format, including what program or process is opening the connection, which port and user, the number of connections per process, the hostname being connected to, the country, and even the city.
Additionally, open_ports shows you all of your open ports listening for connections, again with information about the application, user, port number and name, and even the service IP range. All of the output is color coded, a red background signifies the process is owned by root, red text means the IP address doesn’t correspond to a domain name, blue means the IP matches several domain names, and green text means the protocol is encrypted.
Installation requires some experience with the command line, but chances are if you want an application like this then that won’t be an issue. Here we go…
Installing Open_Ports in Mac OS X
These are are the installation instructions directly from the developers page at Lunds University in Sweden, they have been verified to work in Mac OS X 10.6.8:
Warning: This is a bash script that runs as root that downloads other scripts from the web. This has obvious potential security issues and if you are not comfortable with that or you are in a delicate network environment, this is not recommended to use. The script works as intended, and you can verify the source of the bash script yourself if you want, but if you have any questions or hesitation about running a third party script as root then you may want to use an alternate method to watch open connections, using lsof for example. Proceed at your own risk.
- Fetch the install-script from
- Start a terminal
- Become root: if you are a normal user, type
sudo adminusernamneand then
sudo -iif you are an admin-user, type
- Set access rights for the install script:
chmod 755 open_ports_install.sh(you must locate it)
- Run the script:
- The installation is normally quick. For Linux, that all. On a Mac it ands with GeekTool being opened. To install it, double-click it’s .PrefPane
- In GeekTool: click the icon named ”Shell” and drag it to an empty part of the desktop (must be free of windows). Size it as well.
- A ”Properties”-window opens. What you need to enter is:
- Command: open_ports.sh
- Refresh every: 120 s
- Change font to a monospace-one (I’m using Menlo and white font color)
- Now you may close GeekTool
The other great thing about open_ports is that the Mac OS X version is built to be used in GeekTool, so you can display the output on your Mac desktop. If you’re going to use it through GeekTool, I would suggest using a more plain background picture otherwise the text is hard to read, this is how it looks against the OS X Lion Galaxy wallpaper.
If you want to unintsall open_ports from Mac OS X, use the following commands as root:
launchctl stop se.lth.cs.open_ports
launchctl unload /Library/LaunchDaemons/se.lth.cs.open_ports.plist
Then you can delete the scripts:
rm -rf /usr/bin/open_ports.sh (the script)
rm -rf /Library/LaunchDaemons/se.lth.cs.open_ports.plist (the gather control)
rm -rf /Library/cs.lth.se/OpenPorts (the data files)
In case you were wondering, there is also a Linux version available. I came across this awesome utility on MacWorld, but MacWorld didn’t actually test the script to verify that it works, but I can confirm that it definitely does.