比尔萄堡

上帝说: “要有光” 于是,就有了光。


  • 首页

  • 归档

  • 关于我

  • 公益404

  • 搜索

查看活跃端口 ports

时间: 2022-06-07 分类: 我的小脑/linux   字数: 393 字 阅读: 1分钟 阅读次数:

使用命令

netstat -tuplen

-t tcp连接 -u udp连接 -p, –programs display PID/Program name for sockets -l, –listening display listening server sockets -e, –extend display other/more information -n, –numeric don’t resolve names

netstat status: - time_wait tcp发起断连方,socket会进入该状态,不能被回收使用。该状态是用于保证新分配的socket不受之前延迟重发报文的影响。可通过调整/etc/sysctl.conf中的net.ipv4.tcp_fin_timeout来调整。 - time_close

列出文件

lsof -i:xxxx

列出关联相关端口的文件

time_wait 状态的影响:
  • TCP 连接中,「主动发起关闭连接」的一端,会进入 time_wait 状态
  • time_wait 状态,默认会持续 2 MSL(报文的最大生存时间),一般是 2x2 mins
  • time_wait 状态下,TCP 连接占用的端口,无法被再次使用
  • TCP 端口数量,上限是 6.5w(65535,16 bit)
  • 大量 time_wait 状态存在,会导致新建 TCP 连接会出错,address already in use : connect 异常
机器上有很多time_wait状态的连接,怎么办?
  • 允许 time_wait 状态的 socket 被重用
  • 缩减 time_wait 时间,设置为 1 MSL (MSL is the maximum time a TCP segment is expected to live, or stay in the network. The original TCP specification, RFC 793, defines this as 2 minutes)
#linux# #网络#

标题:查看活跃端口 ports

作者:训导主任林作栋

声明: 本博客文章除特别声明外,均采用 CC BY-NC-SA 3.0许可协议,转载请注明出处!

创作实属不易,如有帮助,那就打赏博主些许茶钱吧 ^_^
WeChat Pay

微信打赏

Alipay

支付宝打赏

后台运行任务
MVCC
训导主任林作栋

训导主任林作栋

戏谑的码农,北野武的拥趸,李安的迷弟,伍佰的Fans

55 日志
23 分类
62 标签
豆瓣
友情链接
  • Obsidian
  • V2EX
  • 关注黑客与极客
  • 廖雪峰
标签云
  • Linux 6
  • K8s 5
  • 数据库 5
  • Golang 4
  • Etcd 3
  • Mysql 3
  • Ai 2
  • Gitlab 2
  • Postgres 2
  • 前端 2
© 2010 - 2024 比尔萄堡
Powered by - Hugo v0.58.2 / Theme by - NexT
/
Storage by Vercel / 刘 ICP 备 18047355 号
0%