netstat 常用组合

参考自:

https://www.cnblogs.com/ftl1012/p/netstat.html

netstat命令用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。netstat是在内核中访问网络及相关信息的程序,它能提供TCP连接,TCP和UDP监听,进程内存管理的相关报告。

netstat常用命令参数:

           -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              don't resolve names

        --numeric-hosts            don't resolve host names

        --numeric-ports            don't resolve port names

        --numeric-users            don't 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

状态(State)说明:

LISTEN:侦听来自远方的TCP端口的连接请求

SYN-SENT:再发送连接请求后等待匹配的连接请求(如果有大量这样的状态包,检查是否中招了)

SYN-RECEIVED:再收到和发送一个连接请求后等待对方对连接请求的确认(如有大量此状态,估计被flood攻击了)

ESTABLISHED:代表一个打开的连接

FIN-WAIT-1:等待远程TCP连接中断请求,或先前的连接中断请求的确认

FIN-WAIT-2:从远程TCP等待连接中断请求

CLOSE-WAIT:等待从本地用户发来的连接中断请求

CLOSING:等待远程TCP对连接中断的确认

LAST-ACK:等待原来的发向远程TCP的连接中断请求的确认(不是什么好东西,此项出现,检查是否被攻击)

TIME-WAIT:等待足够的时间以确保远程TCP接收到连接中断请求的确认

CLOSED:没有任何连接状态

举例:

[songbw@hadoop ~]$ netstat -anp |grep 10070
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
    tcp        0      0 10.130.41.59:10070          0.0.0.0:*                   LISTEN      7578/./ddcs         
    tcp        0      0 127.0.0.1:10070             0.0.0.0:*                   LISTEN      7578/./ddcs         
    tcp        0      0 10.130.41.59:10070          10.130.41.59:55976          ESTABLISHED 7578/./ddcs         
    tcp        0      1 10.130.41.59:36748          10.130.41.232:10070         SYN_SENT    7296/./dcproxy      
    tcp        0      0 10.130.41.59:55976          10.130.41.59:10070          ESTABLISHED 7296/./dcproxy
    
    
    tcp        0      0 10.130.41.59:10070          0.0.0.0:*                   LISTEN      7578/./ddcs
    State 是 LISTEN(侦听状态),表示 ddcs 程序在10.130.41.59机器的 10070端口启动了一个服务,处于侦听状态,供其它程序来连接
    
    tcp        0      0 10.130.41.59:55976          10.130.41.59:10070          ESTABLISHED 7296/./dcproxy
    State 是 ESTABLISHED(打开的连接),表示程序 dcproxy 在端口 55976,连接到了机器 10.130.41.59 的10070端口(即ddcs服务),需要注意的是,连接虽然成功,但是数据不一定发送成功

发布了12 篇原创文章 · 获赞 2 · 访问量 1996

猜你喜欢

转载自blog.csdn.net/weileshenghuo1/article/details/90262488