linux 网络监控命令 netstat
2014-01-19 12:27
344 查看
输出信息含义
一个是Active Internet connections,称为有源TCP连接,其中"Recv-Q"和"Send-Q"指%0A的是接收队列和发送队列。这些数字一般都应该是0。如果不是则表示软件包正在队列中堆积。这种情况只能在非常少的情况见到。另一个是Active UNIX domain sockets,称为有源Unix域套接口(和网络套接字一样,但是只能用于本机通信,性能可以提高一倍)。
Proto显示连接使用的协议,RefCnt表示连接到本套接口上的进程号,Types显示套接口的类型,State显示套接口当前的状态,Path表示连接到套接口的其它进程使用的路径名。
常见参数
-a (all)显示所有选项,默认不显示LISTEN相关-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 Listen (监听) 的服務状态
-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
-e 显示扩展信息,例如uid等
-s 按各个协议进行统计
-c 每隔一个固定时间,执行该netstat命令。
提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到
例子
1. List All Ports (both listening and non listening ports)
List all ports using netstat -aList all tcp ports using netstat -at
List all udp ports using netstat -au
2. List Sockets which are in Listening State
List only listening ports using netstat -lList only listening TCP Ports using netstat -lt
List only listening UDP Ports using netstat -lu
List only the listening UNIX Ports using netstat -lx
3. Show the statistics for each protocol
Show statistics for all ports using netstat -sShow statistics for TCP (or) UDP ports using netstat -st (or) -su
4. Display PID and program names in netstat output using netstat -p
netstat -pt shows all the programs that is connected by tcp protocol5. Don’t resolve host, port and user name in netstat output
This will display in numbers, instead of resolving the host name, port name, user name.Find out on which port a program is running
netstat -ap | grep ssh
nestat -an | grep ':8000'
6. Print netstat information continuously
netstat -c7. Find the non supportive Address families in your system
netstat --verbose8. Display the kernel routing information using netstat -r
Use netstat -rn to display routes in numeric format without resolving for host-names.9. Show the list of network interfaces
netstat -i10.analyze the result
netstat -nat | grep "192.168.1.15:22" |awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -20netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
这里在附加一个常见的Linux面试题。
分析access.log获得访问前10位的ip地址
awk '{print $1}' access.log |sort|uniq -c|sort -nr|head -10
http://www.thegeekstuff.com/2010/03/netstat-command-examples/ http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316661.html
相关文章推荐
- Linux网络监控命令——netstat
- 10 个你需要了解的 Linux 网络和监控命令
- 十个Linux的网络监控命令
- Linux 命令 - netstat: 检查网络设置及相关统计数据
- 11.28 监控io性能 free ps 命令 查看网络状态 linux下抓包
- Linux监控命令整理(top,free,vmstat,iostat,mpstat,sar,netstat)
- 10个Linux 网络和监控命令
- 10个基础的linux网络和监控命令
- Linux的系统调用、网络连接状态、磁盘I/O;可疑行为监控/日志收集、SHELL命令执行流程
- 注意啦!10 个你需要了解的 Linux 网络和监控命令
- Linux网络流量实时监控ifstat iftop命令详解
- netstat命令_Linux netstat 命令用法详解:查看Linux中网络系统状态信息
- 一天一linux命令 netstat 网络相关信息
- linux网络命令 netstat
- 监控io性能/free命令/ps命令/查看网络状况/linux下抓包
- 10 个你需要了解的 Linux 网络和监控命令
- Linux网络流量实时监控ifstat iftop命令详解
- 10.6 监控io性能 10.7 free命令 10.8 ps命令 10.9 查看网络状态 10.10 linux下抓包
- linux命令学习之10个网络命令和监控命令
- 10 个你需要了解的 Linux 网络和监控命令