网络故障排查实用命令手册
一、基本连通性测试
# ping命令 ping 192.168.1.1 # 测试连通性 ping -c 4 8.8.8.8 # 发送4个包 ping -i 0.5 192.168.1.1 # 0.5秒间隔 ping -t 192.168.1.1 # Windows持续ping # traceroute (Linux) / tracert (Windows) traceroute www.google.com # Linux追踪路由 tracert 192.168.1.1 # Windows追踪路由
二、网络配置查看
# Windows ipconfig /all # 查看所有网络配置 ipconfig /release # 释放IP地址 ipconfig /renew # 重新获取IP ipconfig /flushdns # 刷新DNS缓存 # Linux ip addr show # 查看IP地址 ip route show # 查看路由表 ss -tuln # 查看监听端口 netstat -r # 查看路由
三、端口与服务排查
# Windows netstat -ano # 查看所有连接 netstat -ano | find "LISTENING" # 只看监听端口 netstat -ano | findstr ":80" # 查找80端口 # Linux netstat -tulnp # 查看监听端口 netstat -anp # 查看所有连接 lsof -i :80 # 查看80端口被谁占用 # 测试端口连通性 telnet 192.168.1.1 80 # 测试80端口 nc -zv 192.168.1.1 80 # Linux测试端口
四、DNS故障排查
# nslookup nslookup www.example.com # 查询DNS nslookup -type=mx example.com # 查询邮件服务器 # dig (Linux) dig www.example.com # 详细查询 dig @8.8.8.8 www.example.com # 指定DNS服务器 dig -x 8.8.8.8 # PTR记录查询 # 清除缓存 ipconfig /flushdns # Windows清除DNS缓存 systemctl restart systemd-resolved # Linux
五、网络性能测试
# 带宽测试 speedtest-cli # Linux speedtest speedtest.net # 网页测速 # iperf带宽测试 # 服务器端 iperf -s # 客户端 iperf -c server_ip # 查看网络接口状态 ethtool eth0 # Linux查看网卡状态 netsh interface show interface # Windows查看接口