netstat指令详解ITeye - 牛牛娱乐

netstat指令详解ITeye

2019年03月13日12时14分54秒 | 作者: 青旋 | 标签: 显现,数据,衔接 | 浏览: 2315

netstat指令用于显现IP、TCP、UDP和ICMP协议相关的计算数据,对咱们确诊服务器和应用程序的运转状况十分有用。

 

一、netstat参数意义

[root@208 ~]# netstat -help

 

usage: netstat [-veenNcCF] [ Af ] -r netstat {-V|version|-h|help}
 netstat [-vnNcaeol] [ Socket ...]
 netstat { [-veenNac] -I[ Iface ] | [-veenNac] -i | [-cnNe] -M | -s } [delay]
 -r, route display routing table
 -I, interfaces= Iface display interface table for Iface 
 -i, interfaces display interface table
 -g, groups display multicast group memberships
 -s, statistics display networking statistics (like SNMP)
 -M, masquerade display masqueraded connections
 -v, verbose be verbose
 -n, numeric dont resolve names
 numeric-hosts dont resolve host names
 numeric-ports dont resolve port names
 numeric-users dont resolve user names
 -N, symbolic resolve hardware names
 -e, extend display other/more information
 -p, programs display PID/Program name for sockets
 -c, continuous continuous listing
 -l, listening display listening server sockets
 -a, all, listening display all sockets (default: connected)
 -o, timers display timers
 -F, fib display Forwarding Information Base (default)
 -C, cache display routing cache instead of FIB
 -T, notrim stop trimming long addresses
 -Z, context display SELinux security context for sockets
 Iface : Name of interface to monitor/list.
 Socket ={-t|tcp} {-u|udp} {-S|sctp} {-w|raw} {-x|unix} ax25 ipx netrom
 AF =Use -A af  or  af default: inet
 List of possible address families (which support routing):
 inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
 netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
 x25 (CCITT X.25) 

 

 

常用选项 

-s 本选项能够依照各个协议别离显现其计算数据。假如你的应用程序(如Web浏览器)运转速度比较慢,或许不能显现Web页之类的数据,那么你就能够用本选项来检查一下所显现的信息。你需求细心检查计算数据的各行,找到犯错的关键字,进而断定问题所在。 

 

-e 本选项用于显现关于以太网的计算数据。它列出的项目包含传送的数据报的总字节数、过错数、删除数、数据报的数量和播送的数量。这些计算数据既有发送的数据报数量,也有接纳的数据报数量。这个选项能够用来计算一些根本的网络流量。 

 

-r 本选项能够显现关于路由表的信息,类似于后边所讲运用route print指令时看到的 信息。除了显现有用路由外,还显现当时有用的衔接。

 

-a 本选项显现一个一切的有用衔接信息列表,包含已树立的衔接(ESTABLISHED),也包含监听衔接恳求(LISTENING)的那些衔接,断开衔接(CLOSE_WAIT)或许处于联机等候状况的(TIME_WAIT)等。

 

-n 显现一切已树立的有用衔接。netstat支撑用于显现活动或被迫套接字的选项集。选项-t、-u、-w和-x别离表明TCP、UDP、RAW和UNIX套接字衔接。假如你别的还供给了一个-a符号,还会显现出等候衔接(也就是说处于监听形式)的套接字。这样就能够得到一份服务器清单,当时一切运转于体系中的一切服务器都会列入其间。 

 

 

二、用法实例
1、查找某个端口的活动衔接

[root@208 ~]# netstat -ano|grep 9100

 

tcp 0 0 :::9100 :::* LISTEN off (0.00/0/0)
tcp 0 0 ::ffff:192.168.0.208:9100 ::ffff:192.168.0.226:4903 ESTABLISHED keepalive (5575.21/0/0)
tcp 0 0 ::ffff:192.168.0.208:9100 ::ffff:192.168.0.236:2343 ESTABLISHED keepalive (4703.56/0/0)
tcp 0 0 ::ffff:192.168.0.208:9100 ::ffff:192.168.0.235:2765 ESTABLISHED keepalive (5654.58/0/0)
tcp 0 0 ::ffff:192.168.0.208:9100 ::ffff:192.168.0.235:2869 ESTABLISHED keepalive (6246.16/0/0)

 
2、检查TCP端口的监听程序

 

[root@nccd208 ~]# netstat -tlnp

 

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:111 0.0.0.0:* LISTEN 1787/rpcbind 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2186/sshd 
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2079/cupsd 
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2295/master 
tcp 0 0 0.0.0.0:55681 0.0.0.0:* LISTEN 1970/rpc.statd 
tcp 0 0 192.168.0.208:9000 0.0.0.0:* LISTEN 2335/python 
tcp 0 0 127.0.0.1:9001 0.0.0.0:* LISTEN 2340/python 
tcp 0 0 :::8011 :::* LISTEN 28354/java 
tcp 0 0 :::9100 :::* LISTEN 28354/java 
tcp 0 0 :::8012 :::* LISTEN 28354/java 
tcp 0 0 :::1521 :::* LISTEN 2457/tnslsnr 
tcp 0 0 :::22 :::* LISTEN 2186/sshd 
tcp 0 0 ::1:631 :::* LISTEN 2079/cupsd 
tcp 0 0 :::10936 :::* LISTEN 2733/ora_d000_nccd 
tcp 0 0 ::ffff:127.0.0.1:8001 :::* LISTEN 1705/java 
tcp 0 0 :::8003 :::* LISTEN 1705/java 
tcp 0 0 :::9091 :::* LISTEN 1705/java 
tcp 0 0 ::ffff:127.0.0.1:8004 :::* LISTEN 27851/java 
tcp 0 0 :::8005 :::* LISTEN 27851/java 
tcp 0 0 :::8006 :::* LISTEN 27851/java 
tcp 0 0 :::30214 :::* LISTEN 1970/rpc.statd 
tcp 0 0 ::ffff:127.0.0.1:8007 :::* LISTEN 26936/java 
tcp 0 0 :::8008 :::* LISTEN 26936/java 
tcp 0 0 :::8009 :::* LISTEN 26936/java 
tcp 0 0 ::ffff:127.0.0.1:8010 :::* LISTEN 28354/java 

 

 延伸阅览:《》

 

 

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表牛牛娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章