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

推荐订阅源

J
Java Code Geeks
Martin Fowler
Martin Fowler
B
Blog RSS Feed
D
DataBreaches.Net
L
LangChain Blog
月光博客
月光博客
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
美团技术团队
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
小众软件
小众软件
罗磊的独立博客
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta

hwchiu learning note Blog

Kubernetes 怎麼計算 imageFS | hwchiu learning note Nginx Proxy_Pass 不會重新查詢 DNS | hwchiu learning note Multus 下如何透過 network policy 設定 | hwchiu learning note Linux Bridge MTU | hwchiu learning note Kubevirt 初體驗 | hwchiu learning note [MacOS ]隨手筆記 Sed 與 Rename 的使用 | hwchiu learning note Docusaurus 使用 blog mode 後連結一直反白的問題 | hwchiu learning note gcloud 切換帳號 | hwchiu learning note k8s 內安裝 redis-cluster | hwchiu learning note Helm Chart 中如何根據條件來動態安裝 Template 內的物件 | hwchiu learning note GCS 操作上注意事項 | hwchiu learning note istio 操作記錄 | hwchiu learning note terraform | hwchiu learning note Kubernetes GKE 維運上小筆記 | hwchiu learning note Git 修改 author/committer | hwchiu learning note GCP NAT 相關筆記 | hwchiu learning note gcloud ssh 到 GCP VM | hwchiu learning note CloudSQL 收費注意事項 | hwchiu learning note Loki 安裝上的參數調整以及 Ring 的問題除錯 | hwchiu learning note kustomize + helm | hwchiu learning note 觀測 K8s 內 OOM 事件 | hwchiu learning note GKE 上的 RBAC 筆記 | hwchiu learning note 本地產生 jwt token | hwchiu learning note ArgoCD 安裝筆記 | hwchiu learning note CircleCI Context 的使用 | hwchiu learning note 透過 GCP IAP Gateway 來保護 GKE 內的網站 | hwchiu learning note 閱讀筆記: 「SRE 的工作介绍」 | hwchiu learning note 閱讀筆記: 「DevOps is a failure」 | hwchiu learning note 閱讀筆記: 「面試人生 - 設計一個簡易的分散式 Job Scheduler」 | hwchiu learning note 閱讀筆記: 「Cloudflare 06/21 災後報告」 | hwchiu learning note
檢查port使用情況 | hwchiu learning note
2013-03-29 · via hwchiu learning note Blog

有時候根據應用需求,會需要針對去檢查目前系統上有哪些port正在被使用

#[FreeBSD]

可以使用 sockstat 這個command 來檢查系統上port的使用。

USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS

root cron 93468 4 udp4 :638 :*

在預設的情況下,會輸出

使用者名稱,執行的程序,該程序的pid,在該程序中使用該port的file descriptor是多少 使用何種協定,以及address

如果使用 sockstat -4lP tcp 就可以找出 使用tcp & ipv4 ,並且正在listen的port

這對於要尋找是否有人在寫Socket programming來說是很方便的。

詳細的可以man sockstat


#[Linux] 可以使用 netstat 這個工具來檢視,搭配一些參數還可以看到該 port 被那些 process 使用

netstat -anptn
tcp 1 0 127.0.0.1:40147 127.0.0.1:36524 CLOSE_WAIT 7147/vim
tcp 1 0 127.0.0.1:58289 127.0.0.1:52849 CLOSE_WAIT 19421/vi
...

#[Windows]

可以使用netstat來檢視,netstat能夠顯示的資訊非常的多,為了精簡我們的需求,必須去過濾這些資訊

在windows上使用find這個指令,類似於UNIX中grep的功能

舉例來說,netstat -an |find /i “listening" 這個指令

netstat -an 會顯示所有連線以及正在監聽的port,並且以數字的形式來顯示IP以及PORT

find /i “listening" 則會以不區分的方式去搜尋每一行,若包含listening則將該行印出

EX:

TCP 192.168.1.116:139 0.0.0.0:0 LISTENING

TCP 192.168.1.116:49156 216.52.233.65:12975 ESTABLISHED

ref: www.microsoft.com/resources/