Netplan 的静态 IP 导致网速变慢(Ubuntu Server 20.04)

Netplan 的静态 IP 导致网速变慢(Ubuntu Server 20.04)

当我在 Ubuntu Server 20.04 中使用 Netplan 设置静态 IP 时,遇到了网速问题。

我正在使用戴尔 PowerEdge R710,没有 wifi 卡,所以我在论坛上找到的所有涉及 wifi 的解决方案都不起作用。我还尝试了 Netplan 中的其他几种配置以及我在论坛上找到的其他建议,但确实不起作用。

如果我禁用静态 IP 并让其为动态 IP,互联网速度就会很好。有人知道如何解决这个问题吗?

这是我的50-云-初始化.yaml

aiec@camera02:/etc/netplan$ sudo nano 50-cloud-init.yaml
network:
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      addresses: [192.168.253.188/24]
      gateway4: 192.168.253.1
      optional: true
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
  version: 2

速度测试结果(如果我使用动态 IP,速度将达到 40~45 Mbits/s)

aiec@camera02:/etc/netplan$ speedtest
Retrieving speedtest.net configuration...
Testing from Live Telecom (177.66.74.126)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by StarFibra Telecomunicações (Foz do Iguaçu) [4.05 km]: 58.244 ms
Testing download speed................................................................................
Download: 2.12 Mbit/s
Testing upload speed......................................................................................................
Upload: 1.37 Mbit/s

还有配置文件

aiec@camera02:/etc/netplan$ ifconfig -a
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.253.188  netmask 255.255.255.0  broadcast 192.168.253.255
        inet6 fe80::be30:5bff:fefe:671  prefixlen 64  scopeid 0x20<link>
        ether bc:30:5b:fe:06:71  txqueuelen 1000  (Ethernet)
        RX packets 162999  bytes 174965858 (174.9 MB)
        RX errors 0  dropped 6421  overruns 0  frame 0
        TX packets 78785  bytes 42246324 (42.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether bc:30:5b:fe:06:73  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether bc:30:5b:fe:06:75  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno4: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether bc:30:5b:fe:06:77  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1084  bytes 96330 (96.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1084  bytes 96330 (96.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

好的,经过和一些朋友的几次交谈,我们发现了问题所在。其实很简单。

问题出在网关上。当我使用命令时网络状态监测,它返回:

aiec@camera02:~$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.253.1   0.0.0.0         UG        0 0          0 eno1
0.0.0.0         192.168.253.254 0.0.0.0         UG        0 0          0 eno1
192.168.253.0   0.0.0.0         255.255.255.0   U         0 0          0 eno1
192.168.253.254 0.0.0.0         255.255.255.255 UH        0 0          0 eno1

网关必须结束.254,而不是.1

因此,对我来说,使用 netplan 的正确方法是输入网关4:192.168.253.254

  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      addresses: [192.168.253.188/24]
      gateway4: 192.168.253.254
      optional: false
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
  version: 2

现在,我的网络状态监测, 返回:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.253.254 0.0.0.0         UG        0 0          0 eno1
192.168.253.0   0.0.0.0         255.255.255.0   U         0 0          0 eno1

就是这样。感谢那些试图帮助我的人。

答案2

您可能通过 DHCP 收到其他各种会影响吞吐量的设置。如果 IP 地址和网关地址相同,则接下来要查看的是 MTU。如果您的默认 MTU 太大,则由于数据包碎片,您的吞吐量可能会较低。

相关内容