Monday, 20 August 2012

Unclog open ports


  • Difficulty: Intermediate
  • Application: netstat
Generating a list of network ports that are in the Listen state on a Linux server is simple with netstat:
root@catlin:~# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 
tcp 0 0 0.0.0.0:5280 0.0.0.0:* LISTEN 698/perl 
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 217/httpd 
tcp 0 0 10.42.3.2:53 0.0.0.0:* LISTEN 220/named 
tcp 0 0 10.42.4.6:53 0.0.0.0:* LISTEN 220/named 
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 220/named 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 200/sshd 
udp 0 0 0.0.0.0:32768 0.0.0.0:* 220/named 
udp 0 0 10.42.3.2:53 0.0.0.0:* 220/named 
udp 0 0 10.42.4.6:53 0.0.0.0:* 220/named 
udp 0 0 127.0.0.1:53 0.0.0.0:* 220/named 
udp 0 0 0.0.0.0:67 0.0.0.0:* 222/dhcpd 
raw 0 0 0.0.0.0:1 0.0.0.0:* 7 222/dhcpd
That shows you that PID 698 is a Perl process that is bound to port 5280. If you're not root, the system won't disclose which programs are running on which ports.

No comments:

Post a Comment