网络排查分层速查

分层排查

链路层  ip link, ethtool
IP 层   ip addr, ip route, ping
DNS     dig, resolvectl, getent
TCP     ss, nc, traceroute/mtr
TLS     openssl s_client, curl -v
HTTP    curl -v, 网关日志
抓包    tcpdump

常用命令

ip -br addr
ip route
ethtool <iface>
ethtool -S <iface> | grep -i -E 'drop|error|crc'
ping -c 4 <host>
mtr -rwc 50 <host>
ss -lntp
ss -ti
nc -vz -w 5 <host> <port>
dig +short <domain>
dig @<dns-server> <domain>
resolvectl status
curl -v --connect-timeout 5 https://<host>/
openssl s_client -connect <host>:443 -servername <host>
tcpdump -ni any host <host> and port <port>
conntrack -L | head
nft list ruleset

按现象定位

现象 优先检查
Connection refused 端口监听、服务状态、防火墙 REJECT
Connection timeout 路由、安全组 DROP、MTU、backlog
域名解析失败 resolv.conf、上游 DNS、search/ndots
偶发丢包 mtr、网卡错误计数、带宽/QoS
TLS 失败 证书链、SNI、协议/套件、时间
502/504 后端状态、upstream 配置、超时

易错点

相关命令