惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - simhare

Fix “Windows cannot access the specified device path or file” Error Domain Space mysql 登录后 修改密码 git delete repository php - func_get_args mysql key mul - 看不懂 mysql show create table `tablename` 查看建表语句 zend framework assumptions linux vsftpd linux chkconfig pkill kill 看看自己是谁 linux 本地编码-如何解决乱码 linux添加用户-例如oracle 博文阅读密码验证 - 博客园 yum 只下载不安装 linux pts tty linux pts Linux 启动 进入单用户模式 其他用户无法连接 apache start stop
mysql netstat
simhare · 2013-05-01 · via 博客园 - simhare

netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表、实际的网络连接以及每一个网络接口设备的状态信息

输出结果可以分为两个部分,一个是Active Internet connections,另一个是Active UNIX domain sockets.

[root@DBSVR02 conf]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 168.168.80.9:ssh            168.168.80.1:22332          ESTABLISHED
tcp        0      0 168.168.80.9:ssh            168.168.80.1:22864          ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  12     [ ]         DGRAM                    11595  /dev/log
unix  2      [ ]         DGRAM                    8807   @/org/kernel/udev/udevd
unix  2      [ ]         DGRAM                    12403  @/org/freedesktop/hal/udev_event
unix  3      [ ]         STREAM     CONNECTED     15684  /var/lib/mysql/mysql.sock
unix  3      [ ]         STREAM     CONNECTED     15683 
unix  2      [ ]         DGRAM                    14977 
unix  2      [ ]         DGRAM                    14485 
unix  2      [ ]         DGRAM                    13976 
unix  3      [ ]         STREAM     CONNECTED     13438  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     13437 
unix  2      [ ]         DGRAM                    13276 
unix  2      [ ]         DGRAM                    13138 
unix  2      [ ]         DGRAM                    13067 
unix  3      [ ]         STREAM     CONNECTED     13051 
unix  3      [ ]         STREAM     CONNECTED     13050 
unix  3      [ ]         STREAM     CONNECTED     13047 
unix  3      [ ]         STREAM     CONNECTED     13046 

netstat 的常用参数: -t、-u、-w和 -x分别表示TCP、UDP、RAW和UNIX套接字连接。

-a标记,还会显示出等待连接(也就是说处于监听模式)的套接字

-l 显示正在被监听(listen)的端口。

 -n表示直接显示端口数字而不是通过察看/etc/service来转换为端口名

-p选项表示列出监听的程序

[root@DBSVR02 conf]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 0.0.0.0:50790               0.0.0.0:*                   LISTEN     
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN     
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN     
tcp        0      0 168.168.80.9:22             168.168.80.1:22332          ESTABLISHED
tcp        0      0 168.168.80.9:22             168.168.80.1:22864          ESTABLISHED
tcp        0      0 :::42855                    :::*                        LISTEN     
tcp        0      0 :::111                      :::*                        LISTEN     
tcp        0      0 :::80                       :::*                        LISTEN     
tcp        0      0 :::22                       :::*                        LISTEN     
tcp        0      0 ::1:631                     :::*                        LISTEN     
tcp        0      0 ::1:25                      :::*                        LISTEN     
[root@DBSVR02 conf]#

  • 查看当前tcp监听端口

[root@DBSVR02 conf]# netstat -tl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 *:50790                     *:*                         LISTEN     
tcp        0      0 *:sunrpc                    *:*                         LISTEN     
tcp        0      0 *:ssh                       *:*                         LISTEN     
tcp        0      0 localhost:ipp               *:*                         LISTEN     
tcp        0      0 localhost:smtp              *:*                         LISTEN     
tcp        0      0 *:42855                     *:*                         LISTEN     
tcp        0      0 *:sunrpc                    *:*                         LISTEN     
tcp        0      0 *:http                      *:*                         LISTEN     
tcp        0      0 *:ssh                       *:*                         LISTEN     
tcp        0      0 localhost:ipp               *:*                         LISTEN     
tcp        0      0 localhost:smtp              *:*                         LISTEN     
[root@DBSVR02 conf]#

  •  查看当前tcp监听端口, 需要显示监听的程序名,当不清楚mysql的监听端口时比较好用

[root@DBSVR02 conf]# netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 *:50790                     *:*                         LISTEN      1216/rpc.statd     
tcp        0      0 *:sunrpc                    *:*                         LISTEN      1197/rpcbind       
tcp        0      0 *:ssh                       *:*                         LISTEN      1474/sshd          
tcp        0      0 localhost:ipp               *:*                         LISTEN      1360/cupsd         
tcp        0      0 localhost:smtp              *:*                         LISTEN      1550/master        
tcp        0      0 *:42855                     *:*                         LISTEN      1216/rpc.statd     
tcp        0      0 *:sunrpc                    *:*                         LISTEN      1197/rpcbind       
tcp        0      0 *:http                      *:*                         LISTEN      1590/httpd         
tcp        0      0 *:ssh                       *:*                         LISTEN      1474/sshd          
tcp        0      0 localhost:ipp               *:*                         LISTEN      1360/cupsd         
tcp        0      0 localhost:smtp              *:*                         LISTEN      1550/master        
[root@DBSVR02 conf]#