netstat的1基本用法有哪些
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章将为大家详细讲解有关netstat的1基本用法有哪些,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。显示当前所有的链接root@ts:~# netstat -
千家信息网最后更新 2025年12月02日netstat的1基本用法有哪些
这篇文章将为大家详细讲解有关netstat的1基本用法有哪些,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
显示当前所有的链接
root@ts:~# netstat -aActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:domain *:* LISTEN tcp 0 0 testforpaas.21vi:domain *:* LISTEN tcp 0 0 localhost:5433 *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp 0 0 localhost:6010 *:* LISTEN
只显示tcp和dup
root@ts:~# netstat -tau
禁用反向域名解析,加快查询速度
默认情况下 netstat 会通过反向域名解析技术查找每个 IP 地址对应的主机名。这会降低查找速度。如果你觉得 IP 地址已经足够,而没有必要知道主机名,就使用 -n 选项禁用域名解析功能
root@ts:~# netstat -antActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN
只列出监听中的连接
任何网络服务的后台进程都会打开一个端口,用于监听接入的请求。这些正在监听的套接字也和连接的套接字一样,也能被 netstat 列出来。使用 -l 选项列出正在监听的套接字
root@ts:~# netstat -tnlActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN
获取进程名、进程号以及用户 ID
root@ts:~# netstat -tlpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 localhost:domain *:* LISTEN 1080/dnsmasq tcp 0 0 testforpaas.21vi:domain *:* LISTEN 1080/dnsmasq tcp 0 0 localhost:5433 *:* LISTEN 11237/postgres tcp 0 0 localhost:smtp *:* LISTEN 1371/sendmail: MTA:tcp 0 0 localhost:6010 *:* LISTEN 9389/6
获取进程名和用户名
root@ts:~# netstat -tlpeActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program nametcp 0 0 localhost:domain *:* LISTEN root 15870 1080/dnsmasq tcp 0 0 testforpaas.21vi:domain *:* LISTEN root 15868 1080/dnsmasq tcp 0 0 localhost:5433 *:* LISTEN postgres 130080 11237/postgres tcp 0 0 localhost:smtp *:* LISTEN root 17826 1371/sendmail: MTA
显示进程名和用户ID
root@ts:~# netstat -tlpenActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program nametcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 0 15870 1080/dnsmasq tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN 0 15868 1080/dnsmasq tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN 116 130080 11237/postgres tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 0 17826 1371/sendmail: MTA
打印统计数据
netstat 可以打印出网络统计数据,包括某个协议下的收发包数量
root@ts:~# netstat -tnsIcmpMsg: InType0: 93 InType3: 14674 InType11: 27391 OutType3: 18230 OutType8: 38060Tcp: 23583 active connections openings 139747 passive connection openings 21350 failed connection attempts 1512 connection resets received 4 connections established 4263613 segments received 4716472 segments send out 171992 segments retransmited 55 bad segments received. 151266 resets sent
显示内核路由信息
root@ts:~# netstat -rnKernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface0.0.0.0 172.16.16.62 0.0.0.0 UG 0 0 0 ens16010.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 br-9547a5f0faec10.20.0.0 10.20.101.9 255.255.0.0 UG 0 0 0 ppp0
打印网络接口
netstat 也能打印网络接口信息,-i 选项就是为这个功能而生
root@ts:~# netstat -iKernel Interface tableIface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flgbr-9547a5f0faec 1500 0 55883292 0 0 0 89519216 0 0 0 BMRUdocker0 1500 0 49 0 0 0 16 0 0 0 BMUens160 1500 0 152552760 0 611 0 60254997 0 0 0 BMRUlo 65536 0 583345 0 0 0 583345 0 0 0 LRUppp0 1354 0 2157 0 0 0 1679 0 0 0 MOPRUveth6dd978f 1500 0 12751092 0 0 0 18590019 0 0 0 BMRU
输出友好信息
root@ts:~# netstat -eiKernel Interface tablebr-9547a5f0faec Link encap:Ethernet HWaddr 02:42:ee:4b:21:05 inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::42:eeff:fe4b:2105/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:55883460 errors:0 dropped:0 overruns:0 frame:0 TX packets:89519456 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:7839329499 (7.8 GB) TX bytes:199950345292 (199.9 GB)docker0 Link encap:Ethernet HWaddr 02:42:8f:b2:de:7a inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0 inet6 addr: fe80::42:8fff:feb2:de7a/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:49 errors:0 dropped:0 overruns:0 frame:0 TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1372 (1.3 KB) TX bytes:1368 (1.3 KB)
netstat 持续输出
root@ts:~# netstat -cuActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address State udp6 0 0 localhost:37429 localhost:37429 ESTABLISHED
打印 active 状态的连接
netstat -atnp | grep ESTA
监视active状态连接
watch -d -n0 "netstat -atnp | grep ESTA"
关于"netstat的1基本用法有哪些"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
进程
网络
监听
信息
域名
套接字
用户
篇文章
主机
功能
地址
接口
数据
更多
正在
状态
统计数据
速度
统计
输出
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
潮流软件开发参考价格
网关作为dhcp服务器
预付软件开发费怎么入账
电子商务管理与网络技术
ssh跨局域网登录服务器
计算机软件开发P6
服务器隔板
青岛金顺杰网络技术
服务器如何安装自己的应用
幻塔pvp是服务器互通的吗
bscode设置数据库
今年下半年服务器销量
媒体运营好还是网络安全
绵阳网络技术参数
济南众盟网络技术
数据库技术与应用题库
私人服务器电脑配置
数据库中的插值函数
网络服务器应用实训报告
熊瑞金数据库原理与应用出版的书
服务器分多个子服务器
dcs上位机下位机软件开发
网络安全北京应届生平均工资
翰林黄金软件开发
软件开发分前端和后台指什么
枞阳县网络安全工作会议
软件开发工程师转入互联网行业
有关MySQL数据库的论文
main方法连数据库
武汉维凯达软件开发