排查网络问题是运维的日常任务。这篇把最常用的命令和排查思路讲清楚。
一、curl
curl http://localhost:9090/health # GET
curl -X POST -d '{"key":"value"}' http://localhost:9090/api # POST
curl -v http://localhost:9090/health # 查看完整请求响应头
curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9090 # 只看状态码
二、netstat
netstat -tlnp # 所有TCP监听端口
netstat -anp | grep 9090 # 指定端口连接状态
netstat -s # 网络统计信息
三、ss
ss -tln # TCP监听(比netstat快)
ss -s # 连接统计
ss -t state established # 已建立连接
四、tcpdump
tcpdump -i eth0 port 9090 # 抓取9090端口
tcpdump -i eth0 host 192.168.1.100 # 指定IP
tcpdump -i eth0 -w capture.pcap # 保存到文件
💡 觉得有用的话,点赞 + 关注【张老师技术栈】吧!

402

被折叠的 条评论
为什么被折叠?



