在 Linux 系统中,进行网络故障排查时,可以使用多种命令来诊断和解决问题。以下是一些常用的网络排查命令和它们的作用:
ifconfig
或 ip a
:
ifconfig
ip a
ip link
:
ip link
route
或 ip route
:
route -n
ip route
ping
:
ping 8.8.8.8 # 测试到 Google 的 DNS 服务器 ping google.com # 测试到 Google 域名的连通性
ping -c 4
:
ping -c 4 google.com
nslookup
:
nslookup google.com
dig
:
nslookup
提供更多信息。dig google.com
traceroute
或 tracepath
:
traceroute google.com
tracepath google.com
netstat
:
-t
:显示 TCP 连接-u
:显示 UDP 连接-l
:显示监听端口-n
:显示数字格式的地址和端口(避免 DNS 查找)netstat -tuln
ss
:
netstat
更高效的替代工具,查看 socket 连接信息。ss -tuln
ethtool
:
ethtool eth0
mii-tool
:
mii-tool eth0
iperf
:
iperf -s # 服务器端 iperf -c <server-ip> # 客户端
iptables
:
sudo iptables -L
ufw
(如果启用了 UFW 防火墙):
sudo ufw status
dmesg
:
dmesg | grep -i eth
journalctl
:
journalctl -u NetworkManager # 查看 NetworkManager 日志
这些命令可以帮助你快速诊断和定位 Linux 系统上的网络故障,具体使用哪个命令取决于你遇到的问题类型。
版权说明:如非注明,本站文章均为 扬州驻场服务-网络设备调试-监控维修-南京泽同信息科技有限公司 原创,转载请注明出处和附带本文链接。
请在这里放置你的在线分享代码