环境:CentOS 6.5 64bit
netstat常用参数说明:
netstat -atunlp
- -a :all,表示列出所有的连接,服务监听,Socket资料
- -t :tcp,列出tcp协议的服务
- -u :udp,列出udp协议的服务
- -n :port number, 用端口号来显示
- -l :listening,列出当前监听服务
- -p :program,列出服务程序的PID
[root@localhost conf]# netstat -atunlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 44988/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1834/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1728/cupsd
tcp 0 0 10.209.177.82:25 0.0.0.0:* LISTEN 1986/master
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1986/master
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 5231/mysqld
tcp 0 0 10.209.177.82:22 10.209.177.40:52408 ESTABLISHED 2470/sshd
tcp 1 0 10.209.177.82:32815 104.116.243.18:80 CLOSE_WAIT 2452/clock-applet
tcp 0 0 :::22 :::* LISTEN 1834/sshd
tcp 0 0 ::1:631 :::* LISTEN 1728/cupsd
tcp 0 0 :::88 :::* LISTEN 44896/httpd
tcp 0 0 ::1:25 :::* LISTEN 1986/master
udp 0 0 0.0.0.0:631 0.0.0.0:* 1728/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1726/dhclient
其中
- Proto:网络传输协议,主要为tcp和udp
- Local Address:本地的ip:port
- Foreign Address:远程主机的ip:port
- State:连线状态,主要有监听( LISTEN )和建立(ESTABLISED)
- PID:服务的进程编号
- Program name:服务名称