深圳网站论坛建设,做国外销售都上什么网站,北京做app的公司有哪些,wordpress产品图片框文章目录
netstat
命令介绍
语法格式
基本参数
显示各列内容分析
1#xff09;netstat -a显示各列内容分析
2#xff09;netstat -r显示各列内容分析
3#xff09;netstat -i 显示各列内容分析
参考实例
1#xff09;显示系统网络状态的所有连接
2#xff09;…文章目录
netstat
命令介绍
语法格式
基本参数
显示各列内容分析
1netstat -a显示各列内容分析
2netstat -r显示各列内容分析
3netstat -i 显示各列内容分析
参考实例
1显示系统网络状态的所有连接
2显示系统网络状态的UDP连接信息
3显示网卡状态信息
4显示网络路由表信息
5查看关于sshd的PID值
6) 使用管道符查看某个在运行的服务信息
7访问每种协议的统计信息
命令总结
netstat
命令介绍
通过帮助文档了解命令的含义 NAME netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships netstat 的英文单词“network statistics”命令主要功能用于各种网络相关信息例显示网络连接状态、路由表信息、接口状态、NAT、多播成员等信息。
语法格式
netstat的命令参数能用上的其实挺多的可以看到帮助文档中能使用的参数格式很丰富。
默认的语法依然还是netstat 【参数】 SYNOPSIS netstat [address_family_options] [--tcp|-t] [--udp|-u] [--udplite|-U] [--sctp|-S] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users] [--symbolic|-N] [--extend|-e[--extend|-e]] [--timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c] [--wide|-W] [delay] ...... 基本参数
此命令的常用参数有以下这些也有几种是常用搭配的格式以表格形式显示
-a显示所有连线中的Socket-n不使用主机名加服务名称以IP端口的形式显示-t列出tcp网络封包的数据-u列出udp网络封包的数据-p列出该网络服务的进程PID-r列出路由表信息-i列出网卡信息-l仅列出在监听的服务状态
显示各列内容分析
1netstat -a显示各列内容分析
man参考文档中有说明到每列代表的含义一起来看下。
OUTPUTActive Internet connections (TCP, UDP, UDPLite, raw)ProtoThe protocol (tcp, udp, udpl, raw) used by the socket.Recv-Q
......通过netstat -a显示所有在监听的服务信息并分析各列内容的含义。
netstat参考图协议Protocol 表示网络连接的协议类型例如tcp、udp等协议接收队列Recv-Q 接收socket套接字队列中的数据量以字节为单位发送队列Send-Q 发送socket套接字队列中的数据量以字节为单位本地地址Local Address运行netstat命令的本地计算机地址外部地址Foreign Address位于网络另一端的计算机地址状态State 每个服务网络连接的状态 2netstat -r显示各列内容分析 目标Destination 目标计算机的地址 网关Gateway 中间网关地址网络掩码Genmask 网络掩码用于指定网络中的可用主机标志Flags 指定是哪种路由 MSS 默认最大段的大小窗口Window 默认窗口大小初始往返时间irtt 发送信号并接收其确认的总时间接口lface 数据包将通过其路由的接口3netstat -i 显示各列内容分析 接口Iface接口类型 MTU 最大传输单位 RX 接收数据包 TX 发送数据包 OK 无错误的数据包 ERR 有错误的数据包 DRP 丢包的数量 OVR 数据包由于溢出而丢失 Fig 定义接口配置的标志 参考实例
1显示系统网络状态的所有连接
[rootlocalhost ~]# netstat -a | head
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN
tcp 0 0 localhost.locald:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 localhost:ipp 0.0.0.0:* LISTEN
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:ipp [::]:* LISTEN 2显示系统网络状态的UDP连接信息
[rootlocalhost ~]# netstat -anu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:875 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:36816 0.0.0.0:*
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:* 3显示网卡状态信息
[rootlocalhost ~]# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
ens32 1500 456 0 0 0 366 0 0 0 BMRU
lo 65536 4 0 0 0 4 0 0 0 LRU
virbr0 1500 0 0 0 0 0 0 0 0 BMU4显示网络路由表信息
[rootlocalhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default gateway 0.0.0.0 UG 0 0 0 ens32
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 ens325查看关于sshd的PID值
[rootlocalhost ~]# netstat -p | grep ssh
unix 3 [ ] STREAM CONNECTED 26245 1216/sshd 6) 使用管道符查看某个在运行的服务信息
[rootVM-12-17-centos ~]# netstat -antup | grep httpd
tcp6 0 0 :::80 :::* LISTEN 322/httpd
tcp6 0 0 :::443 :::* LISTEN 322/httpd 7访问每种协议的统计信息
[rootlocalhost ~]# netstat -s
Ip:463 total packets received0 forwarded0 incoming packets discarded220 incoming packets delivered310 requests sent out81 dropped because of missing route
Icmp:2 ICMP messages received0 input ICMP message failed.ICMP input histogram:destination unreachable: 23 ICMP messages sent
......
命令总结 netstat命令要学的参数其实是挺多的关于网络方面的状态信息这个命令显示的都很全面了如果需要查看服务是否运行即可使用这个命令查看是否再监听状态。若觉得以上内容还行的可以点赞支持一下