#!/bin/bash
sudo netstat -lantp | grep ESTABLISHED |awk '{print $5}' | awk -F: '{print $1}' | sort -u


syntax highlighted by Code2HTML, v. 0.9.1