在Ubuntu系统中,可使用tcpdump(命令行)或Wireshark(图形化)工具分析网络问题,步骤如下:
sudo apt update && sudo apt install tcpdump
sudo apt update && sudo apt install wireshark
# 配置非root用户权限(可选)
sudo usermod -aG wireshark $USER
newgrp wireshark
选择网卡:
sudo tcpdump -i eth0(eth0替换为目标网卡名)。eth0、wlan0)开始抓包。过滤流量:
sudo tcpdump -i eth0 port 80。sudo tcpdump -i eth0 host 192.168.1.1。http、tcp.port == 80等表达式。保存抓包文件:
sudo tcpdump -i eth0 -w capture.pcap(后续用Wireshark分析)。追踪流→TCP流)。RST(连接重置)或ICMP Destination Unreachable包。Time列(响应时间),或使用Statistics→IO Graphs分析流量趋势。tcp.analysis.retransmission过滤器查看TCP重传情况。404、500)、DNS解析错误(响应时间过长或超时)。Conversations(会话统计)查看主机间通信量,Endpoints(端点统计)定位异常主机。Expert Info汇总潜在问题(如重传、乱序)。通过以上步骤,可系统化定位网络连接、延迟、协议等异常问题。