How do I view active or listening network connections on my Linux server?

netstat - ‘netstat’ is the command available within Linux or Windows like
operating systems to display any active or listening connections on
the host it is executed from.

To display all active and listening connections in number form:

netstat -an

sample output from command:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:14667 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.1:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.1:14667 192.168.1.5:3736 ESTABLISHED
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 :::443 :::* LISTEN
tcp 0 1288 ::ffff:192.168.1.1:22 ::ffff:192.168.1.:57159 ESTABLISHED
udp 0 0 192.168.1.1:123 0.0.0.0:*
udp 0 0 127.0.0.1:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 5477 /var/run/cgisock
unix 2 [ ACC ] STREAM LISTENING 5489 /var/lib/courier-imap
unix 2 [ ACC ] STREAM LISTENING 5390 /dev/log
unix 2 [ ACC ] STREAM LISTENING 5432 /var/run/mysqld/mysql
unix 3 [ ] STREAM CONNECTED 13982488
unix 3 [ ] STREAM CONNECTED 13982487
unix 3 [ ] STREAM CONNECTED 13981805 /dev/log
unix 3 [ ] STREAM CONNECTED 13981804
unix 3 [ ] STREAM CONNECTED 13981428 /dev/log
unix 3 [ ] STREAM CONNECTED 13981427
unix 3 [ ] STREAM CONNECTED 13979824 /dev/log
unix 3 [ ] STREAM CONNECTED 13979823
unix 3 [ ] STREAM CONNECTED 13978466 /dev/log
unix 3 [ ] STREAM CONNECTED 13978465
unix 3 [ ] STREAM CONNECTED 13978131 /dev/log
unix 3 [ ] STREAM CONNECTED 13978130
unix 3 [ ] STREAM CONNECTED 13977738 /var/run/mysqld/mys
unix 3 [ ] STREAM CONNECTED 13977737
unix 3 [ ] STREAM CONNECTED 13976598 /var/run/mysqld/mys
unix 3 [ ] STREAM CONNECTED 13976597
unix 2 [ ] STREAM CONNECTED 13639900
unix 2 [ ] STREAM CONNECTED 13380238
unix 2 [ ] STREAM CONNECTED 12179495
unix 3 [ ] STREAM CONNECTED 7913329 /dev/log
unix 3 [ ] STREAM CONNECTED 7913328
unix 3 [ ] STREAM CONNECTED 48940 /dev/log
unix 3 [ ] STREAM CONNECTED 48939
unix 3 [ ] STREAM CONNECTED 5981 /dev/log
unix 3 [ ] STREAM CONNECTED 5980
unix 3 [ ] STREAM CONNECTED 5864 /dev/log
unix 3 [ ] STREAM CONNECTED 5863
unix 3 [ ] STREAM CONNECTED 5678 /dev/log
unix 3 [ ] STREAM CONNECTED 5677
unix 3 [ ] STREAM CONNECTED 5645 /dev/log
unix 3 [ ] STREAM CONNECTED 5644
unix 3 [ ] STREAM CONNECTED 5493 /dev/log
unix 3 [ ] STREAM CONNECTED 5492

Example line from above explained:

tcp 0 0 192.168.1.1:80 0.0.0.0:* LISTEN

This line indicates that the address 192.168.1.1 bound to this host
is listening on tcp port 80 (the standard http port for web
traffic).  “Listening” means a service is waiting for an incoming
connection on a specific port to provide its service to
clients/users.  An “active connection” means that a user/client is
already connected to the server on a specific port.

 

Your rating: None Average: 3.7 (5 votes)