[root@localhost ~]# netstat [选项]
选项:
[root@localhost ~]# netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0:::11211 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
udp 0 0 0.0.0.0:11211 0.0.0.0:*
udp 0 0:::11211 :::*
#协议接收队列发送队列本机的 IP 地址及端口号 远程主机的 IP 地址及端口号 状态
[root@localhost ~]# netstat -tulnp
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:3306 0.0.0.0:* LISTEN 2359/mysqld
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 1563/memcached
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1490/sshd
tcp 0 0 :::11211 :::* LISTEN 1563/memcached
tcp 0 0 :::80 :::* LISTEN 21025/httpd
tcp 0 0 :::22 :::*
LISTEN 1490/sshd
udp 0 0 0.0.0.0:11211 0.0.0.0:* 1563/memcached
udp 0 0:::11211 :::* 1563/memcached
#比之前的命令多了一个"-p"选项,结果多了可以知道是哪个程序占用了端口
[root@localhost ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
tcp 0 0 117.79.130.170:80 78.46.174.55:58815 SYN_RECV
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 117.79.130.170:22 124.205.129.99:10379 ESTABLISHED
tcp 0 0 117.79.130.170:22 124.205.129.99:11811 ESTABLISHED
...省略部分内容...
udp 0 0 0.0.0.0:11211 0.0.0.0:*
udp 0 0:::11211 :::*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ACC] STREAM LISTENING 9761 @/var/run/hald/dbus-fr41WkQn1C
…省略部分内容...
Copyright © 广州京杭网络科技有限公司 2005-2024 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有