跳转至

网络诊断:需要检查什么以及向技术支持发送什么

在这篇文章中

开始之前

网络问题表现为速度低、丢包、延迟高或连接间歇性中断。要缩小原因范围:

  1. 暂时禁用两端的防火墙,或确保防火墙不会干扰测试。请参阅防火墙配置。
  2. 检查服务器的资源使用情况:当 CPU 负载达到 100% 时,服务器无法以全速处理流量。
  3. 检查您是否收到了超出预付流量的通知——在这种情况下,速度会自动降低。

提示

无需订购服务器,即可使用 Speed Test 和 Looking Glass 检查到 HOSTKEY 网络的速度。

在以下所有命令中,请将 SERVER_IP 替换为您服务器的 IP 地址,将 CLIENT_IP 替换为您的外部 IP 地址(可以使用 curl -4 ifconfig.me 查看)。

使用 ping 检查可达性

# Linux/macOS
ping -c 50 SERVER_IP

# Windows
ping -n 50 SERVER_IP

请注意 packet loss 的百分比以及响应时间的波动范围(min/avg/max)。没有回复并不总是意味着服务器不可达:ICMP 可能被防火墙阻止,例如 Windows Server 默认就是如此。

使用 traceroute 和 tracert 查看路由

# Linux (CentOS/Alma/Rocky: sudo dnf install traceroute, CentOS 7: sudo yum install traceroute)
traceroute SERVER_IP

# TCP route to a specific port (if ICMP/UDP is filtered)
sudo traceroute -T -p 443 SERVER_IP

# Windows
tracert SERVER_IP

路由显示数据包经过哪些节点,以及延迟在哪个网段上增加。

使用 mtr 检查路由上的丢包

mtr 结合了 ping 和 traceroute 的功能,并显示每个节点上的丢包情况。安装:sudo apt install mtr-tiny、sudo dnf install mtr 或 sudo yum install mtr。在 Windows 上,请使用 WinMTR。

以报告模式运行测试:

mtr -r -w -c 100 SERVER_IP > mtr_to_server.txt

警告

去程和回程路由经常经过不同的节点。请务必**在两个方向上**运行测试:从您的计算机到服务器,以及从服务器到您的计算机。

在服务器上:

mtr -r -w -c 100 CLIENT_IP > mtr_to_client.txt

如何解读结果

  • 仅在某个中间节点出现丢包,而后续节点和目标节点没有丢包,这不是问题。路由器会限制 ICMP 回复的速率并以低优先级响应,而转发流量则不会丢失。
  • 从某个节点开始出现并一直持续到路由末端(包括目标节点)的丢包,表示该网段或其后存在实际问题。
  • 在某个节点处延迟突然增加并在之后保持较高水平,表示该网段上的链路拥塞或物理距离较远。
  • 最后一行(服务器本身)的数值最为重要:如果显示 0% 丢包,则到服务器的网络工作正常。

使用 iperf3 测量吞吐量

请使用 iperf3 测量吞吐量——其他工具的结果准确度较低。安装:sudo apt install iperf3、sudo dnf install iperf3 或 sudo yum install iperf3。

所有位置的 HOSTKEY 公共 iperf3 服务器列在网络速度测试中。阿姆斯特丹的示例:

# the client sends, the server receives
iperf3 -c spd-nlsrv.hostkey.com -p 5201 -P 10 -4

# reverse mode: the server sends, the client receives
iperf3 -c spd-nlsrv.hostkey.com -p 5201 -P 10 -4 -R

要测试您的计算机与服务器之间的链路,请在服务器上以服务器模式运行 iperf3,并从客户端连接到它:

# on the server (open port 5201/tcp in the firewall)
iperf3 -s

# on the client
iperf3 -c SERVER_IP -P 10 -4
iperf3 -c SERVER_IP -P 10 -4 -R

分别从您的服务器到最近的 HOSTKEY iperf3 服务器、从您的计算机到您的服务器进行测量——这样可以判断速度是在服务器端受限,还是在到您这一侧的网段上受限。

服务器端检查

网络接口错误

ip -s link show

errors、dropped 和 overrun 计数器不断增长,表示存在驱动程序问题、过载或硬件故障。在专用服务器上,还需检查端口速率和双工模式:

sudo ethtool eth0          # Speed, Duplex, Link detected
sudo ethtool -S eth0 | grep -iE 'err|drop|crc'

请将 eth0 替换为 ip link 输出中的接口名称。在虚拟服务器上,ethtool 可能不显示速率——这是正常的。

在 Windows 上,可以使用以下命令查看适配器统计信息:

Get-NetAdapterStatistics
Get-NetAdapter | Format-Table Name, Status, LinkSpeed

防火墙

确保服务器上的防火墙没有阻止所需的端口和 ICMP。Invapi 控制面板中没有防火墙设置——请在操作系统中检查规则。详细信息请参阅防火墙配置。

MTU

MTU 不正确会导致小请求可以通过,而大请求(加载页面、传输文件、VPN)挂起。检查当前值:

ip link show | grep mtu

检查 1500 字节的数据包是否能在不分片的情况下通过(1472 字节数据 + 28 字节报头):

# Linux
ping -M do -s 1472 -c 4 SERVER_IP

# Windows
ping -f -l 1472 SERVER_IP

如果收到 Message too long 或 Packet needs to be fragmented,请减小数据包大小,直到数据包能够通过——这样就能找到路径上的实际 MTU。MTU 问题最常出现在 VPN 和隧道中。

需要向技术支持发送哪些信息

您可以通过两种方式联系技术支持:使用账户中指定的电子邮件地址发送邮件,或在 Invapi 控制面板的 Help Center 中创建工单(如何创建工单)。

如果问题仍未解决,请从账户中指定的电子邮件地址向技术支持发送以下信息:

Server IP address: SERVER_IP
Your external IP address, city, and ISP: CLIENT_IP, ...
Problem description: what exactly is slow, since when,
constantly or intermittently (specify the time and time zone)

Attachments:
1. mtr_to_server.txt — mtr from your computer to the server
2. mtr_to_client.txt — mtr from the server to your computer
3. iperf3 results (normal and with the -R flag), including the commands used
4. Output of ip -s link show from the server
5. Result of the test on speedtest.hostkey.com (screenshot)

备注

为了更准确地进行诊断,请在不同时间(包括问题发生时)进行多次测试。