how to find out which ports are open?

run this command as root:

netstat -tulpn

t - tcp

u - udp

l - listenning

p - programs

n - dont resolve names

exmaple output:

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:805                 0.0.0.0:*             LISTEN      4439/rpc.statd     
tcp        0       0           0.0.0.0:111                 0.0.0.0:*             LISTEN      4400/portmap       
tcp        0       0           :::8098                     :::*                        LISTEN      2960/java          
tcp        0       0           :::8009                     :::*                        LISTEN      2960/java          
tcp        0       0           :::1099                     :::*                        LISTEN      2960/java          
tcp        0       0           :::8080                     :::*                        LISTEN      2960/java          
tcp        0       0           :::8083                     :::*                        LISTEN      2960/java          
tcp        0       0           :::22                         :::*                        LISTEN      4698/sshd

...


udp        0      0            0.0.0.0:32768        0.0.0.0:*                                  4868/avahi-daemon: 
udp        0      0            0.0.0.0:799            0.0.0.0:*                                  4439/rpc.statd     
udp        0      0            0.0.0.0:802            0.0.0.0:*                                  4439/rpc.statd     
udp        0      0            0.0.0.0:5353          0.0.0.0:*                                  4868/avahi-daemon: 
...

 
udp        0      0            :::123                      :::*                                          4734/ntpd 

 ---------------------------

on Windows, try this command: (option o: the owningg process ID associated with the connection)

netstat -anto | findstr 4848

example output:

c:\>netstat -anto | findstr 4848
  TCP    0.0.0.0:4848           0.0.0.0:0              LISTENING       3652     InHost
  TCP    127.0.0.1:4848         127.0.0.1:58533        ESTABLISHED     3652     InHost
  TCP    127.0.0.1:4848         127.0.0.1:58536        ESTABLISHED     3652     InHost
  TCP    127.0.0.1:58533        127.0.0.1:4848         ESTABLISHED     3280     InHost
  TCP    127.0.0.1:58536        127.0.0.1:4848         ESTABLISHED     3280     InHost

------------- kill a Windows process

c:\>taskkill /F /PID 3652
SUCCESS: The process with PID 3652 has been terminated.

猜你喜欢

转载自jxee.iteye.com/blog/1660769