Ubuntu Server 20.04.4 LTS 网络缓慢/不工作

Ubuntu Server 20.04.4 LTS 网络缓慢/不工作

我的网络问题最初始于 DNS 错误,因此我开始尝试将 DNS 服务器更改为 Cloudflare/Google DNS。我开始阅读如何执行此操作,并发现最新的 Ubuntu 版本使用 Netplan。

Netplan 的配置存储在 中/etc/netplan/,但当我查看此文件夹时,我发现只有一个文件,该文件名为 00-install.yml 或类似名称。在搜索和测试了一些东西后,我发现我的网络没有使用/etc/network/interfaces(此文件为空/不存在),我刚开始创建新的 Netplan 配置。

经过多次重启和无屏幕输入后,我终于让它工作了。DNS 在大多数应用程序中仍然不起作用,再次谷歌搜索后我发现我必须更改/etc/resolv.conf符号链接?????? 这很奇怪,但我这样做了,现在 resolv.conf 中的 DNS 等于我的 Netplan 配置中的 DNS(/etc/netplan/01-cfg.yml),并且一切正常。

直到我尝试下载 LinuxGSM 服务器。./gmodserver install命令开始从 Github(或 Bitbucket,失败时使用 CURL)逐个下载一些 shell 脚本,然后开始下载,然后一些脚本下载失败,脚本失败。在重新运行命令 20 多次并重新启动后,脚本终于可以正常工作了。

从那一刻起,网络问题变得更糟了。Ping 和 curl 大多停止工作。我找到了一个答案,说尝试远程登录到 Google,它成功了,但速度很慢。我尝试解决这个问题:使用 DHCP/静态 IP、更改 IP、更改名称服务器、删除名称服务器选项,从 Netplan 切换到 ifupdown ( /etc/network/interfaces)

我目前拥有的:

Ubuntu 20.04.4 LTS x86_64,ifupdown 网络,UFW 禁用,Cloudflare DNS,Ping 随机丢包:

stopper@stopperls:~$ ping [Ubuntu Changelogs]
PING [Ubuntu Changelogs] 56(84) bytes of data.
64 bytes from amyrose.canonical.com: icmp_seq=1 ttl=53 time=168 ms
# ... worked another 12 times
^C
--- [Ubuntu Changelogs] ping statistics ---
19 packets transmitted, 13 received, 31.5789% packet loss, time 18131ms
rtt min/avg/max/mdev = 166.969/167.842/168.108/0.275 ms
# It's starting fine, but then stops working:
stopper@stopperls:~$ ping [Ubuntu Changelogs]
PING [Ubuntu Changelogs] 56(84) bytes of data.
^C
--- [Ubuntu Changelogs] ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1014ms
# Tried disabling IPv6 (already disabled in some sysctl file but this file is looks like ignored for some reason):
stopper@stopperls:~$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
[sudo] password for stopper: 
net.ipv6.conf.all.disable_ipv6 = 1
stopper@stopperls:~$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6 = 1
stopper@stopperls:~$ ping [Ubuntu Changelogs]
PING [Ubuntu Changelogs] (185.125.190.17) 56(84) bytes of data.
^C
--- [Ubuntu Changelogs] ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3052ms
# And it started working for a little bit again:
stopper@stopperls:~$ ping [Ubuntu Changelogs]
PING [Ubuntu Changelogs] 56(84) bytes of data.
# ... worked another 8 times
^C
--- [Ubuntu Changelogs] ping statistics ---
16 packets transmitted, 8 received, 50% packet loss, time 15162ms
rtt min/avg/max/mdev = 166.739/167.794/168.258/0.418 ms

在 SSH 连接上,我得到Failed to connect to [Ubuntu Changelogs]/meta-release-lts. Check your Internet connection or proxy settings

冰壶运动[Google]有时会中断:

stopper@stopperls:~$ curl [Google]
curl: (56) Recv failure: Connection reset by peer
stopper@stopperls:~$ curl [Google]
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="[Google]">here</A>.
</BODY></HTML>
# ... worked another 5 times
stopper@stopperls:~$ curl [Google]
# Was frozen for a minute+
curl: (7) Failed to connect to [Google] port 80: Connection timed out
stopper@stopperls:~$ curl [Google]
curl: (56) Recv failure: Connection reset by peer

enp4s0 是主接口 - 板载 Realtek RTL8111D

04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 03)
        Subsystem: Gigabyte Technology Co., Ltd Onboard Ethernet
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 31
        Region 0: I/O ports at ee00 [size=256]
        Region 2: Memory at fbcff000 (64-bit, prefetchable) [size=4K]
        Region 4: Memory at fbcf8000 (64-bit, prefetchable) [size=16K]
        Expansion ROM at fbd00000 [virtual] [disabled] [size=128K]
        Capabilities: [40] Power Management version 3
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee08004  Data: 4024
        Capabilities: [70] Express (v2) Endpoint, MSI 01
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
                        ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 10.000W
                DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
                        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
                        MaxPayload 128 bytes, MaxReadReq 4096 bytes
                DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+ TransPend-
                LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s <512ns, L1 <64us
                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp-
                LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 2.5GT/s (ok), Width x1 (ok)
                        TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis+, NROPrPrP-, LTR-
                         10BitTagComp-, 10BitTagReq-, OBFF Not Supported, ExtFmt-, EETLPPrefix-
                         EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
                         FRS-, TPHComp-, ExtTPHComp-
                         AtomicOpsCap: 32bit- 64bit- 128bitCAS-
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
                         AtomicOpsCtl: ReqEn-
                LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
                         Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
                         Compliance De-emphasis: -6dB
                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
        Capabilities: [ac] MSI-X: Enable- Count=4 Masked-
                Vector table: BAR=4 offset=00000000
                PBA: BAR=4 offset=00000800
        Capabilities: [cc] Vital Product Data
pcilib: sysfs_read_vpd: read failed: Input/output error
                Not readable
        Capabilities: [100 v1] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr-
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
                AERCap: First Error Pointer: 00, ECRCGenCap+ ECRCGenEn- ECRCChkCap+ ECRCChkEn-
                        MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
                HeaderLog: 00000000 00000000 00000000 00000000
        Capabilities: [140 v1] Virtual Channel
                Caps:   LPEVC=0 RefClk=100ns PATEntryBits=1
                Arb:    Fixed- WRR32- WRR64- WRR128-
                Ctrl:   ArbSelect=Fixed
                Status: InProgress-
                VC0:    Caps:   PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
                        Arb:    Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
                        Ctrl:   Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
                        Status: NegoPending- InProgress-
        Capabilities: [160 v1] Device Serial Number 03-00-00-00-68-4c-e0-00
        Kernel driver in use: r8168
        Kernel modules: r8168

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.32.1    0.0.0.0         UG    0      0        0 enp4s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-44b6209c823e
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-ec985c658a3b
172.20.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-50806f0cc08b
172.21.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-8d4bdd62462b
192.168.32.0    0.0.0.0         255.255.255.0   U     0      0        0 enp4s0
192.168.32.0    0.0.0.0         255.255.255.0   U     0      0        0 br-c709a7686d7e

ifconfig

br-44b6209c823e: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:3c:4f:7a:1a  txqueuelen 0  (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

br-50806f0cc08b: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.20.0.1  netmask 255.255.0.0  broadcast 172.20.255.255
        ether 02:42:5b:90:b1:1a  txqueuelen 0  (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

br-8d4bdd62462b: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.21.0.1  netmask 255.255.0.0  broadcast 172.21.255.255
        ether 02:42:ff:b3:27:4c  txqueuelen 0  (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

br-c709a7686d7e: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.32.1  netmask 255.255.255.0  broadcast 192.168.32.255
        ether 02:42:bb:26:20:58  txqueuelen 0  (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

br-ec985c658a3b: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        ether 02:42:90:ae:ea:6b  txqueuelen 0  (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

docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:e7:47:61:e2  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53  bytes 8827 (8.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.32.108  netmask 255.255.255.0  broadcast 192.168.32.255
        ether 1c:6f:65:21:0c:cb  txqueuelen 1000  (Ethernet)
        RX packets 354430  bytes 21343825 (21.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2036  bytes 137535 (137.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 # note that 0 dropped
        device interrupt 31  base 0xd000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 86  bytes 6220 (6.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 6220 (6.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth050959f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 5e:ea:3a:8b:e8:61  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53  bytes 8827 (8.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 1c:6f:65:21:0c:cb brd ff:ff:ff:ff:ff:ff
    inet 192.168.32.108/24 brd 192.168.32.255 scope global enp4s0
       valid_lft forever preferred_lft forever
3: br-50806f0cc08b: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:5b:90:b1:1a brd ff:ff:ff:ff:ff:ff
    inet 172.20.0.1/16 brd 172.20.255.255 scope global br-50806f0cc08b
       valid_lft forever preferred_lft forever
4: br-8d4bdd62462b: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:ff:b3:27:4c brd ff:ff:ff:ff:ff:ff
    inet 172.21.0.1/16 brd 172.21.255.255 scope global br-8d4bdd62462b
       valid_lft forever preferred_lft forever
5: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:e7:47:61:e2 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
6: br-c709a7686d7e: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:bb:26:20:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.32.1/24 brd 192.168.32.255 scope global br-c709a7686d7e
       valid_lft forever preferred_lft forever
7: br-ec985c658a3b: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:90:ae:ea:6b brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-ec985c658a3b
       valid_lft forever preferred_lft forever
8: br-44b6209c823e: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:3c:4f:7a:1a brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-44b6209c823e
       valid_lft forever preferred_lft forever
10: veth050959f@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 5e:ea:3a:8b:e8:61 brd ff:ff:ff:ff:ff:ff link-netnsid 0

cat /etc/network/interfaces

stopper@stopperls:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug enp4s0
auto enp4s0
iface enp4s0 inet static
  address 192.168.32.108
  netmask 255.255.255.0
  broadcast 192.168.32.255
  gateway 192.168.32.1
  dns-nameservers 1.1.1.1 1.0.0.1

也没有代理:

stopper@stopperls:~$ echo "$http_proxy"

stopper@stopperls:~$ echo "$https_proxy"

stopper@stopperls:~$ echo "$all_proxy"

stopper@stopperls:~$

在 Manjaro 机器上,CURL 运行完美,PING 也是如此(而且一般来说,我的 Manjaro PC 上没有任何网络问题,DNS 服务器是自动的(所以可能不是 Cloudflare/Google DNS,可能是这个 DNS 在 Ubuntu 服务器上出现了问题))

相关内容