Seeing All Servers You Are Connected To |

Seeing All Servers You Are Connected To

With Linux and Unix systems, it's easy to figure out what external systems your computer or server is connected to. For instance, to see which external servers my local desktop applications are connected to, I ran this (I've removed some of the output for illustration purposes):

# netstat -W -p --tcp
tcp        0      0 ESTABLISHED 13208/pidgin
tcp        0      0 ESTABLISHED 2774/chrome

As you can see, it first lists the local port from which the socket to the external server is opened. Really nifty to illustrate the number of ports that are in play on your local computer in order to make the various connections/sockets open to the outside world.

Seeing All Running Services on Your Host

Anothernetstat command I'm often using is one that tells me what services are on a given host. The below command give me all the ports, PIDs and programs that are listening for incoming TCP connections on the current host:

# netstat -W -nlp  --tcp

[..] tcp 0 0 LISTEN 1770/nginx tcp 0 0 LISTEN 1473/varnishd tcp 0 0 LISTEN 3257/sshd tcp 0 0 LISTEN 1994/slapd tcp 0 0* LISTEN 1963/mysqld [..]

There's Even More

netstat has so many more options, but this should at least weten your apatite :-) See its well written man page for more options and explanations. Also note that the options to the command vary from system. E.g. Linux typically has more "comfort" options than Solaris and Mac OS.

gmail torstein.k.johansen @ gmail ~ twitter @torsteinkrause ~