A more portable way to check this is to use
netstat -an.
Code:
netstat -an -f inet
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp 0 0 *.80 *.* LISTEN
tcp 0 0 *.6000 *.* LISTEN
tcp 0 0 127.0.0.1.587 *.* LISTEN
tcp 0 0 127.0.0.1.25 *.* LISTEN
tcp 0 0 *.22 *.* LISTEN
tcp 0 0 *.515 *.* LISTEN
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
udp 0 0 192.168.222.20.20996 81.171.44.131.123
udp 0 0 192.168.222.20.31964 131.211.187.240.123
udp 0 0 192.168.222.20.25209 81.171.46.247.123
udp 0 0 192.168.222.20.22752 62.93.230.13.123
udp 0 0 192.168.222.20.35148 194.109.153.91.123
udp 0 0 *.514 *.*
Leaving out the
-n option will make it even more readable
Code:
netstat -a -f inet
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp 0 0 hercules.8448 mu-in-f91.google.www ESTABLISHED
tcp 0 0 *.www *.* LISTEN
tcp 0 0 *.6000 *.* LISTEN
tcp 0 0 localhost.submissi *.* LISTEN
tcp 0 0 localhost.smtp *.* LISTEN
tcp 0 0 *.ssh *.* LISTEN
tcp 0 0 *.printer *.* LISTEN
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
udp 0 0 hercules.20996 ams1.x31.com.ntp
udp 0 0 hercules.31964 ruumzp.med.uu.nl.ntp
udp 0 0 hercules.25209 vm196.contextshi.ntp
udp 0 0 hercules.22752 sectionzero.org.ntp
udp 0 0 hercules.35148 ntp.t.niet.net.ntp
udp 0 0 *.syslog *.*
BTW this is on OpenBSD, which doesn't have a
sockstat.