一、iftop

1.简介 一个类似top的实时监控工具,可以用来监控网卡的实时流量、反向解析IP、显示端口信息等等, 高级的监控有TCP/IP连接等。

2.安装 2.1安装额外仓库源 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

2.2快速安装 [root@leo ~]# yum install iftop

2.3在命令行输入命令: [root@leo ~]# iftop

出现这个界面:

3.命令相关参数及说明 3.1 界面说明

界面上面显示的是类似刻度尺的刻度范围,为显示流量图形的长条作标尺用的。 中间的<= =>这两个左右箭头,表示的是流量的方向。 TX:发送流量 RX:接收流量 TOTAL:总流量 Cumm:运行iftop到目前时间的总流量 peak:流量峰值 rates:分别表示过去 2s 10s 40s 的平均流量

3.2 命令参数 3.2.1 官方全参:

   -h                  display this message
   -n                  don't do hostname lookups
   -N                  don't convert port numbers to services
   -p                  run in promiscuous mode (show traffic between other
                       hosts on the same network segment)
   -b                  don't display a bar graph of traffic
   -B                  Display bandwidth in bytes
   -i interface        listen on named interface
   -f filter code      use filter code to select packets to count
                       (default: none, but only IP packets are counted)
   -F net/mask         show traffic flows in/out of IPv4 network
   -G net6/mask6       show traffic flows in/out of IPv6 network
   -l                  display and count link-local IPv6 traffic (default: off)
   -P                  show ports as well as hosts
   -m limit            sets the upper limit for the bandwidth scale
   -c config file      specifies an alternative configuration file
   -t                  use text interface without ncurses

   Sorting orders:
   -o 2s                Sort by first column (2s traffic average)
   -o 10s               Sort by second column (10s traffic average) [default]
   -o 40s               Sort by third column (40s traffic average)
   -o source            Sort by source address
   -o destination       Sort by destination address

   The following options are only available in combination with -t
   -s num              print one single text output afer num seconds, then quit
   -L num              number of lines to print

3.2.2常用参数(未进入界面时使用):

-i  指定监测的网卡
-B 以bytes为单位显示流量(默认是bits)
-n 使host信息默认直接都显示IP
-N 使端口信息默认直接都显示端口号
-F  显示指定网段的进出流量
-h  显示帮助信息
-p  使用这个参数后,中间的列表显示的本地主机信息,出现了本机以外的IP信息;
-b  使流量图形条默认就显示;
-f   这个暂时还不太会用,过滤计算包用的;
-P  使host信息及端口信息默认就都显示;
-m 设置界面最上边的刻度的最大值,刻度分五个大段显示,例:# iftop -m 100M

3.2.3 交互参数(进入界面后使用):

按h切换是否显示帮助; 按n切换显示本机的IP或主机名; 按s切换是否显示本机的host信息; 按d切换是否显示远端目标主机的host信息; 按t切换显示格式为2行/1行/只显示发送流量/只显示接收流量; 按N切换显示端口号或端口服务名称; 按S切换是否显示本机的端口信息; 按D切换是否显示远端目标主机的端口信息; 按p切换是否显示端口信息; 按P切换暂停/继续显示; 按b切换是否显示平均流量图形条; 按B切换计算2秒或10秒或40秒内的平均流量; 按T切换是否显示每个连接的总流量; 按l打开屏幕过滤功能,输入要过滤的字符,比如ip,按回车后,屏幕就只显示这个IP相关的流量信息; 按L切换显示画面上边的刻度;刻度不同,流量图形条会有变化; 按j或按k可以向上或向下滚动屏幕显示的连接记录; 按1或2或3可以根据右侧显示的三列流量数据进行排序; 按<根据左边的本机名或IP排序; 按>根据远端目标主机的主机名或IP排序; 按o切换是否固定只显示当前的连接; 按f可以编辑过滤代码,这是翻译过来的说法,我还没用过这个! 按!可以使用shell命令,这个没用过!没搞明白啥命令在这好用呢! 按q退出监控。

二、ss

1.简介 用来显示处于活动状态的套接字信息。ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息,而且比netstat更快速更高效,特别当服务器的socket数量变得非常大的时候,更显SS得优势。

2.安装:重点 ss 命令利用到了 TCP 协议栈中 tcp_diag。tcp_diag 是一个用于分析统计的模块,属于Linux内核自带的,然而想ifconfig命令就不是内核自带的,需要额外安装软件包。

3.参数说明 3.1官方参数:

-h, --help          this message
   -V, --version       output version information
   -n, --numeric       don't resolve service names
   -r, --resolve       resolve host names
   -a, --all           display all sockets
   -l, --listening     display listening sockets
   -o, --options       show timer information
   -e, --extended      show detailed socket information
   -m, --memory        show socket memory usage
   -p, --processes     show process using socket
   -i, --info          show internal TCP information
   -s, --summary       show socket usage summary
   -b, --bpf           show bpf filter socket information
   -E, --events        continually display sockets as they are destroyed
   -Z, --context       display process SELinux security contexts
   -z, --contexts      display process and socket SELinux security contexts
   -N, --net           switch to the specified network namespace name

   -4, --ipv4          display only IP version 4 sockets
   -6, --ipv6          display only IP version 6 sockets
   -0, --packet        display PACKET sockets
   -t, --tcp           display only TCP sockets
   -S, --sctp          display only SCTP sockets
   -u, --udp           display only UDP sockets
   -d, --dccp          display only DCCP sockets
   -w, --raw           display only RAW sockets
   -x, --unix          display only Unix domain sockets
       --vsock         display only vsock sockets
   -f, --family=FAMILY display sockets of type FAMILY
       FAMILY := {inet|inet6|link|unix|netlink|vsock|help}

   -K, --kill          forcibly close sockets, display what was closed
   -H, --no-header     Suppress header line

   -A, --query=QUERY, --socket=QUERY
       QUERY := {all|inet|tcp|udp|raw|unix|unix_dgram|unix_stream|unix_seqpacket|packet|netlink|vsock_stream|vsock_dgram}[,QUERY]

   -D, --diag=FILE     Dump raw information about TCP sockets to FILE
   -F, --filter=FILE   read filter information from FILE

3.2 常用参数

-h:显示帮助信息;
-V:显示指令版本信息;
-n:不解析服务名称,以数字方式显示;
-a:显示所有的套接字;
-l:显示处于监听状态的套接字;
-o:显示计时器信息;
-m:显示套接字的内存使用情况;
-p:显示使用套接字的进程信息;
-i:显示内部的TCP信息;
-4:只显示ipv4的套接字;
-6:只显示ipv6的套接字;
-t:只显示tcp套接字;
-u:只显示udp套接字;
-d:只显示DCCP套接字;
-w:仅显示RAW套接字;
-x:仅显示UNIX域套接字。

3.3实例:显示socket摘要

[root@leo ~]# ss -t -a
State       Recv-Q Send-Q                         Local Address:Port                                          Peer Address:Port                
LISTEN      0      128                                        *:ssh                                                      *:*                    
LISTEN      0      100                                127.0.0.1:smtp                                                     *:*                    
ESTAB       0      52                           192.168.116.128:ssh                                          192.168.116.1:60008                
LISTEN      0      128                                       :::ssh                                                     :::*                    
LISTEN      0      100                                      ::1:smtp                                                    :::*                    
[root@leo ~]# ss -pl  #正在使用的socket

三、vnstat

1.简介

vnstat是一个应用于Linux或BSD平台,对网卡流量做监控。 因为并非是基于网络包嗅探的方式而是基于/proc的分析。现在vnStat已经有出vnstat PHP frontend 扩展了,可以以PHP脚本的形式直接调用vnStat监测的数据。

2.快速安装 [root@leo ~]# yum install -y vnstat

3.说明 3.1官方参数

         -q,  --query          query database
         -h,  --hours          show hours
         -d,  --days           show days
         -m,  --months         show months
         -w,  --weeks          show weeks
         -t,  --top10          show top 10 days
         -s,  --short          use short output
         -u,  --update         update database
         -i,  --iface          select interface (default: eth0)
         -?,  --help           short help
         -v,  --version        show version
         -tr, --traffic        calculate traffic
         -ru, --rateunit       swap configured rate unit
         -l,  --live           show transfer rate in real time

3.2 常用参数

vnstat -i eth0 -l #实时流量情况 vnstat -i eth0 -h #按小时查询流量情况 vnstat -i eth0 -d #按天数查询流量情况 vnstat -i eth0 -m #按月数查询流量情况 vnstat -i eth0 -w #按周数查询流量情况 vnstat -i eth0 -t #查询TOP10流量情况

3.3 示例:实时显示接口流量情况

[root@leo ~]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.116.128  netmask 255.255.255.0  broadcast 192.168.116.255
        inet6 fe80::20c:29ff:fe49:de1f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:49:de:1f  txqueuelen 1000  (Ethernet)
        RX packets 12328  bytes 13529530 (12.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4200  bytes 431348 (421.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@leo ~]# vnstat -i ens33 -l
Monitoring ens33...    (press CTRL-C to stop)

   rx:        0 kbit/s     0 p/s          tx:        1 kbit/s     0 p/s

   rx:        1 kbit/s     1 p/s          tx:        1 kbit/s     1 p/s
   rx:        0 kbit/s     0 p/s          tx:        1 kbit/s     0 p/s

四、top

1.简介

实时动态地查看系统的整体运行情况,是一个综合了多方信息监测系统性能和运行信息的实用工具。通过top命令所提供的互动式界面,用热键可以管理。

2.安装 内核自带,iotop需要通过安装使用。

3.说明 3.1官方参数: top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

3.2 常用参数解析:

-b:以批处理模式操作;
-c:显示完整的治命令;
-d:屏幕刷新间隔时间;
-I:忽略失效过程;
-s:保密模式;
-S:累积模式;
-i<时间>:设置间隔时间;
-u<用户名>:指定用户名;
-p<进程号>:指定进程;
-n<次数>:循环显示的次数。

3.3 参数交互(进入top界面后使用)

h:显示帮助画面,给出一些简短的命令总结说明; k:终止一个进程; i:忽略闲置和僵死进程,这是一个开关式命令; q:退出程序; r:重新安排一个进程的优先级别; S:切换到累计模式; s:改变两次刷新之间的延迟时间(单位为s),如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5s; f或者F:从当前显示中添加或者删除项目; o或者O:改变显示项目的顺序; l:切换显示平均负载和启动时间信息; m:切换显示内存信息; t:切换显示进程和CPU状态信息; c:切换显示命令名称和完整命令行; M:根据驻留内存大小进行排序; P:根据CPU使用百分比大小进行排序; T:根据时间/累计时间进行排序; w:将当前设置写入~/.toprc文件中。

3.4 界面说明

[root@leo ~]# top 
top - 11:22:17 up 45 min,  1 user,  load average: 0.00, 0.01, 0.05
Tasks: 122 total,   1 running, 121 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.1 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3863568 total,  3317288 free,   160336 used,   385944 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.  3426700 avail Mem 

说明:

top - 11:22:17[当前系统时间], up 45 min [系统已经运行45分], 1 user[用户登录数量], load average: 0.00, 0.01, 0.05[系统负载时间段记录] Tasks: 122 total[总进程数], 1 running[正在运行的进程数], 121 sleeping[睡眠的进程数], 0 stopped[停止的进程数], 0 zombie[冻结进程数], %Cpu(s): 0.1 us[用户空间占用CPU百分比], 0.1 sy[内核空间占用CPU百分比], 0.0 ni[用户进程空间内改变过优先级的进程占用CPU百分比], 99.8 id[空闲CPU百分比], 0.0 wa[等待输入输出的CPU时间百分比], 0.0 hi[], 0.0 si[], 0.0 st[], KiB Mem : 3863568 total[物理内存总量], 3317288 free[空闲内存总量], 160336 used[使用的物理内存总量], 385944 buff/cache[用作内核缓存的内存量] KiB Swap: 2097148 total[交换区总量], 2097148 free[空闲交换区总量], 0 used[使用的交换区总量], 3426700 avail Mem[缓冲的交换区总量],

五、Ping

1.简介

Ping是Windows、Unix和Linux系统下的一个命令。ping也属于一个通信协议,是TCP/IP协议的一部分。利用“ping”命令可以检查网络是否连通,可以很好地帮助我们分析和判定网络故障。

2.安装 内核自带

3.说明 3.1 官方参数

Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
            [-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
             [-l preload] [-m mark] [-M pmtudisc_option]
             [-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize]
             [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline]
             [-W timeout] destination

3.2 常用参数

-d:使用Socket的SO_DEBUG功能; -c<完成次数>:设置完成要求回应的次数; -f:极限检测; -i<间隔秒数>:指定收发信息的间隔时间; -I<网络界面>:使用指定的网络界面送出数据包; -l<前置载入>:设置在送出要求信息之前,先行发出的数据包; -n:只输出数值; -p<范本样式>:设置填满数据包的范本样式; -q:不显示指令执行过程,开头和结尾的相关信息除外; -r:忽略普通的Routing Table,直接将数据包送到远端主机上; -R:记录路由过程; -s<数据包大小>:设置数据包的大小; -t<存活数值>:设置存活数值TTL的大小; -v:详细显示指令的执行过程。

** 3.3实例:发送报文到目的主机**

[root@leo ~]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=7.18 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=8.00 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=7.43 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=7.60 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=128 time=8.16 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=6 ttl=128 time=8.31 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5010ms
rtt min/avg/max/mdev = 7.184/7.785/8.311/0.411 ms
[root@leo ~]# 

六、lsof

1.简介

用于查看你进程开打的文件,打开文件的进程,进程打开的端口(TCP、UDP)。找回/恢复删除的文件。是十分方便的系统监视工具,因为lsof命令需要访问核心内存和各种文件,所以需要root用户执行。 在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件。所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。

2.快速安装 [root@leo ~]# yum install -y lsof

3.说明 3.1官方参数

-?|-h list help          -a AND selections (OR)     -b avoid kernel blocks
  -c c  cmd c ^c /c/[bix]  +c w  COMMAND width (9)    +d s  dir s files
  -d s  select by FD set   +D D  dir D tree *SLOW?*   +|-e s  exempt s *RISKY*
  -i select IPv[46] files  -K list tasKs (threads)    -l list UID numbers
  -n no host names         -N select NFS files        -o list file offset
  -O no overhead *RISKY*   -P no port names           -R list paRent PID
  -s list file size        -t terse listing           -T disable TCP/TPI info
  -U select Unix socket    -v list version info       -V verbose search
  +|-w  Warnings (+)       -X skip TCP&UDP* files     -Z Z  context [Z]
  -- end option scan     
  +f|-f  +filesystem or -file names     +|-f[gG] flaGs 
  -F [f] select fields; -F? for help  
  +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0)
                                        +m [m] use|create mount supplement
  +|-M   portMap registration (-)       -o o   o 0t offset digits (8)
  -p s   exclude(^)|select PIDs         -S [t] t second stat timeout (15)
  -T qs TCP/TPI Q,St (s) info
  -g [s] exclude(^)|select and print process group IDs
  -i i   select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list]
  +|-r [t[m<fmt>]] repeat every t seconds (15);  + until no files, - forever.
       An optional suffix to t is m<fmt>; m must separate t from <fmt> and
      <fmt> is an strftime(3) format for the marker line.
  -s p:s  exclude(^)|select protocol (p = TCP|UDP) states by name(s).
  -u s   exclude(^)|select login|UID set s
  -x [fl] cross over +d|+D File systems or symbolic Links

3.2 常用参数

-a:列出打开文件存在的进程; -c<进程名>:列出指定进程所打开的文件; -g:列出GID号进程详情; -d<文件号>:列出占用该文件号的进程; +d<目录>:列出目录下被打开的文件; +D<目录>:递归列出目录下被打开的文件; -n<目录>:列出使用NFS的文件; -i<条件>:列出符合条件的进程。(4、6、协议、:端口、 @ip ) -p<进程号>:列出指定进程号所打开的文件; -u:列出UID号进程详情; -h:显示帮助信息; -v:显示版本信息。

3.3 实例

[root@leo ~]# lsof |head -n 10
COMMAND    PID  TID    USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
systemd      1         root  cwd       DIR              253,0       224         64 /
systemd      1         root  rtd       DIR              253,0       224         64 /
systemd      1         root  txt       REG              253,0   1612152   50692855 /usr/lib/systemd/systemd
systemd      1         root  mem       REG              253,0     20112      34479 /usr/lib64/libuuid.so.1.3.0
systemd      1         root  mem       REG              253,0    261456      34481 /usr/lib64/libblkid.so.1.1.0
systemd      1         root  mem       REG              253,0     90664      34241 /usr/lib64/libz.so.1.2.7
systemd      1         root  mem       REG              253,0    157424      34472 /usr/lib64/liblzma.so.5.2.2
systemd      1         root  mem       REG              253,0     23968      34508 /usr/lib64/libcap-ng.so.0.0.0
systemd      1         root  mem       REG              253,0     19896      34292 /usr/lib64/libattr.so.1.1.0
[root@leo ~]# 

解释:

COMMAND:进程的名称 PID:进程标识符 PPID:父进程标识符(需要指定-R参数) USER:进程所有者 PGID:进程所属组 FD:文件描述符,应用程序通过文件描述符识别该文件。 TYPE:文件类型 DEVICE:指定磁盘名称 SIZE/OFF:文件大小 NODE:索引节点(文件在磁盘上的标识) NAME:文件的确切名称

七、tcpdump

1.简介

一款sniffer工具,它可以打印所有经过网络接口的数据包的头信息,也可以使用-w选项将数据包保存到文件中,方便以后分析。

2.快速安装

[root@leo ~]# yum install -y tcpdump

3.说明 3.1 官方参数

tcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ]
		[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
		[ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ]
		[ -Q|-P in|out|inout ]
		[ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ]
		[ --immediate-mode ] [ -T type ] [ --version ] [ -V file ]
		[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]
		[ -Z user ] [ expression ]

3.2 常用参数

-a:尝试将网络和广播地址转换成名称;
-c<数据包数目>:收到指定的数据包数目后,就停止进行倾倒操作;
-d:把编译过的数据包编码转换成可阅读的格式,并倾倒到标准输出;
-dd:把编译过的数据包编码转换成C语言的格式,并倾倒到标准输出;
-ddd:把编译过的数据包编码转换成十进制数字的格式,并倾倒到标准输出;
-e:在每列倾倒资料上显示连接层级的文件头;
-f:用数字显示网际网络地址;
-F<表达文件>:指定内含表达方式的文件;
-i<网络界面>:使用指定的网络截面送出数据包;
-l:使用标准输出列的缓冲区;
-n:不把主机的网络地址转换成名字;
-N:不列出域名;
-O:不将数据包编码最佳化;
-p:不让网络界面进入混杂模式;
-q :快速输出,仅列出少数的传输协议信息;
-r<数据包文件>:从指定的文件读取数据包数据;
-s<数据包大小>:设置每个数据包的大小;
-S:用绝对而非相对数值列出TCP关联数;
-t:在每列倾倒资料上不显示时间戳记;
-tt: 在每列倾倒资料上显示未经格式化的时间戳记;
-T<数据包类型>:强制将表达方式所指定的数据包转译成设置的数据包类型;
-v:详细显示指令执行过程;
-vv:更详细显示指令执行过程;
-x:用十六进制字码列出数据包资料;
-w<数据包文件>:把数据包数据写入指定的文件。

3.3实例: 3.3.1直接监控第一个在网络接口流过的数据包 [root@leo ~]# tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on bluetooth0, link-type BLUETOOTH_HCI_H4_WITH_PHDR (Bluetooth HCI UART transport layer plus pseudo-header), capture size 262144 bytes

3.3.2监控指定主机端口的数据包 [root@leo ~]# tcpdump -i ens33

八、nc

1.简介

netcat命令的简称,都是用来设置路由器。

2.快速安装 [root@leo ~]# yum install nc

3.说明 3.1 官方参数

 -4                         Use IPv4 only
  -6                         Use IPv6 only
  -U, --unixsock             Use Unix domain sockets only
  -C, --crlf                 Use CRLF for EOL sequence
  -c, --sh-exec <command>    Executes the given command via /bin/sh
  -e, --exec <command>       Executes the given command
      --lua-exec <filename>  Executes the given Lua script
  -g hop1[,hop2,...]         Loose source routing hop points (8 max)
  -G <n>                     Loose source routing hop pointer (4, 8, 12, ...)
  -m, --max-conns <n>        Maximum <n> simultaneous connections
  -h, --help                 Display this help screen
  -d, --delay <time>         Wait between read/writes
  -o, --output <filename>    Dump session data to a file
  -x, --hex-dump <filename>  Dump session data as hex to a file
  -i, --idle-timeout <time>  Idle read/write timeout
  -p, --source-port port     Specify source port to use
  -s, --source addr          Specify source address to use (doesn't affect -l)
  -l, --listen               Bind and listen for incoming connections
  -k, --keep-open            Accept multiple connections in listen mode
  -n, --nodns                Do not resolve hostnames via DNS
  -t, --telnet               Answer Telnet negotiations
  -u, --udp                  Use UDP instead of default TCP
      --sctp                 Use SCTP instead of default TCP
  -v, --verbose              Set verbosity level (can be used several times)
  -w, --wait <time>          Connect timeout
  -z                         Zero-I/O mode, report connection status only
      --append-output        Append rather than clobber specified output files
      --send-only            Only send data, ignoring received; quit on EOF
      --recv-only            Only receive data, never send anything
      --allow                Allow only given hosts to connect to Ncat
      --allowfile            A file of hosts allowed to connect to Ncat
      --deny                 Deny given hosts from connecting to Ncat
      --denyfile             A file of hosts denied from connecting to Ncat
      --broker               Enable Ncat's connection brokering mode
      --chat                 Start a simple Ncat chat server
      --proxy <addr[:port]>  Specify address of host to proxy through
      --proxy-type <type>    Specify proxy type ("http" or "socks4" or "socks5")
      --proxy-auth <auth>    Authenticate with HTTP or SOCKS proxy server
      --ssl                  Connect or listen with SSL
      --ssl-cert             Specify SSL certificate file (PEM) for listening
      --ssl-key              Specify SSL private key (PEM) for listening
      --ssl-verify           Verify trust and domain name of certificates
      --ssl-trustfile        PEM file containing trusted SSL certificates
      --ssl-ciphers          Cipherlist containing SSL ciphers to use
      --version              Display Ncat's version information and e

3.2 常用参数

-g<网关>:设置路由器跃程通信网关,最多设置8个; -G<指向器数目>:设置来源路由指向器,其数值为4的倍数; -h:在线帮助; -i<延迟秒数>:设置时间间隔,以便传送信息及扫描通信端口; -l:使用监听模式,监控传入的资料; -n:直接使用ip地址,而不通过域名服务器; -o<输出文件>:指定文件名称,把往来传输的数据以16进制字码倾倒成该文件保存; -p<通信端口>:设置本地主机使用的通信端口; -r:指定源端口和目的端口都进行随机的选择; -s<来源位址>:设置本地主机送出数据包的IP地址; -u:使用UDP传输协议; -v:显示指令执行过程; -w<超时秒数>:设置等待连线的时间; -z:使用0输入/输出模式,只在扫描通信端口时使用。

3.3 实例 参数:

主机:指定主机的IP地址或主机名称; 端口号:可以是单个整数或者是一个范围。

端口扫描:

[root@leo ~]# nc -v -w 1  192.168.116.128 -z 1-10

192.168.116.128 是要监控的服务器IP

九、nethogs

1.简介

一个开源的命令行工具(类似于Linux的top命令),用来按进程或程序实时统计网络带宽使用率。

2.快速安装 [root@leo ~]# yum install nethogs -y

3.说明 3.1 官方参数

usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [device [device [device ...]]]
		-V : prints version.
		-h : prints this help.
		-b : bughunt mode - implies tracemode.
		-d : delay for update refresh rate in seconds. default is 1.
		-v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
		-c : number of updates. default is 0 (unlimited).
		-t : tracemode.
		-p : sniff in promiscious mode (not recommended).
		-s : sort output by sent column.
   -a : monitor all devices, even loopback/stopped ones.
device : device(s) to monitor. default is all interfaces up and running excluding loopback

3.2 常用参数1(非交互)

-d : 刷新间隔 -h : 帮助 -p : promiscious 模式 -t : trace模式 -V : 版本

3.3 常用参数2(交互式)

m : 修改单位 r : 按流量排序 s : 按发送流量排序 q : 退出命令提示符

3.4 实例 监控网络带宽; [root@leo ~]# nethogs ens33

改变刷新频率: [root@leo ~]# nethogs ens33 -d 5

十、nslookup

1.简介

常用域名查询工具,就是查DNS信息用的命令。 nslookup4有两种工作模式,即“交互模式”和“非交互模式”。在“交互模式”下,用户可以向域名服务器查询各类主机、域名的信息,或者输出域名中的主机列表。而在“非交互模式”下,用户可以针对一个主机或域名仅仅获取特定的名称或所需信息。

2.快速安装 [root@leo ~]# yum install -y bind-utils

3.2 参数说明 -sil:不显示任何警告信息。

3.3 实例

[root@leo ~]# nslookup www.baidu.com
Server:		192.168.116.2
Address:	192.168.116.2#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 14.215.177.38
Name:	www.a.shifen.com
Address: 14.215.177.39

[root@leo ~]# 

更多的博客转移到个人博客上了,请点击以下链接:

个人博客