Virtualbox 中的 Debian VM 流量緩慢
我在 VirtualBox 中使用 Debian Buster VM 作為 Windows 10 筆記本的路由器。
$$ for reasons not worth mentioning here $$ 它已經執行了幾天,但昨天和今天的流量變得異常緩慢且不可靠 - 在我家相對穩定的網路中。包括主機在內的其他設備工作正常。重新啟動虛擬機(並且只有虛擬機)可以修復它
$$ little $$然而,問題很快又令人惱火地回來了。 仔細檢查後,我在控制台和
/var/log/syslog
.出現類似問題/錯誤的 eth0 和 eth1 介面是虛擬網路介面卡。
真正的設備主機是帶有 Intel Dual Band Wireless-AC 3165 的 Lenovo ThinkPad E560 Intel i7,這是 eth0 NAT 後面的真正 NIC。
但是,eth1 是內部網路的虛擬網路介面,它只與 windows 主機上的另一個虛擬網路介面通信,並且與真實網路介面卡或外部流量無關。因此,該問題似乎不僅與(外部/真實)網路或主機的物理介面相關。
Virtual Box 版本是 5.2.12 r122591 (Qt5.6.2)。我還在有問題的 VM 中安裝了 Virtual Box 工具。
怎麼了?
有問題的介面:
# ip a 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:f6:32:22 brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:82:0f:24 brd ff:ff:ff:ff:ff:ff inet 4.1.1.1/24 brd 4.1.1.255 scope global eth1 valid_lft forever preferred_lft forever
lspci
有問題的 VM 的輸出。$ lspci 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service 00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB 00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08) 00:08.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
eth0 的錯誤。Eth1 也出現了同樣的錯誤。
Jun 25 08:32:22 rui kernel: [31950.194099] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:32:25 rui kernel: [31952.306456] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:32:54 rui kernel: [31981.448886] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:32:59 rui kernel: [31987.206829] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 23 20:40:58 rui systemd[1]: Started ifup for eth0. Jun 23 20:40:58 rui kernel: [ 1.671922] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:f6:32:22 Jun 23 20:40:58 rui kernel: [ 1.672229] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection Jun 23 20:40:59 rui ifup[570]: /sbin/ifup: waiting for lock on /run/network/ifstate.eth0 Jun 23 20:40:59 rui kernel: [ 4.760724] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 23 20:40:59 rui dhclient[581]: Listening on LPF/eth0/08:00:27:f6:32:22 Jun 23 20:40:59 rui sh[563]: Listening on LPF/eth0/08:00:27:f6:32:22 Jun 23 20:40:59 rui dhclient[581]: Sending on LPF/eth0/08:00:27:f6:32:22 Jun 23 20:40:59 rui sh[563]: Sending on LPF/eth0/08:00:27:f6:32:22 Jun 23 20:40:59 rui dhclient[581]: DHCPREQUEST of 10.0.2.15 on eth0 to 255.255.255.255 port 67 (xid=0x1211b42a) Jun 23 20:40:59 rui sh[563]: DHCPREQUEST of 10.0.2.15 on eth0 to 255.255.255.255 port 67 (xid=0x1211b42a) Jun 23 20:40:59 rui sh[563]: ifup: interface eth0 already configured Jun 25 08:33:16 rui dhclient[644]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0xac0f1c44) Jun 25 08:33:16 rui dhclient[644]: DHCPREQUEST of 10.0.2.15 on eth0 to 255.255.255.255 port 67 (xid=0x441c0fac) Jun 25 08:33:45 rui kernel: [ 38.195899] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:34:23 rui kernel: [ 76.277453] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:34:37 rui kernel: [ 89.824132] NETDEV WATCHDOG: eth0 (e1000): transmit queue 0 timed out Jun 25 08:34:37 rui kernel: [ 89.831381] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:34:39 rui kernel: [ 92.002061] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:37:59 rui kernel: [ 292.064298] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:38:01 rui kernel: [ 294.148491] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:38:12 rui kernel: [ 304.388066] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:38:37 rui kernel: [ 329.952311] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:38:39 rui kernel: [ 332.064828] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:38:56 rui kernel: [ 349.313777] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:39:01 rui kernel: [ 354.242015] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:39:03 rui kernel: [ 356.258135] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:39:04 rui kernel: [ 357.298945] e1000 0000:00:03.0 eth0: Detected Tx Unit Hang Jun 25 08:39:05 rui kernel: [ 357.857091] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:39:07 rui kernel: [ 359.968627] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:40:45 rui kernel: [ 457.982736] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:40:47 rui kernel: [ 460.132984] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:41:28 rui kernel: [ 500.480653] e1000: eth0 NIC Link is Down Jun 25 08:41:28 rui kernel: [ 500.480767] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:41:30 rui kernel: [ 502.755753] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:41:40 rui kernel: [ 512.834548] e1000: eth0 NIC Link is Down Jun 25 08:41:40 rui kernel: [ 512.834570] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:41:42 rui kernel: [ 515.008848] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:41:52 rui kernel: [ 525.031738] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:41:55 rui kernel: [ 527.668391] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:42:21 rui kernel: [ 553.953056] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:42:23 rui kernel: [ 556.033233] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:42:38 rui kernel: [ 570.848721] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:42:40 rui kernel: [ 573.025803] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:42:55 rui kernel: [ 588.001188] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:42:58 rui kernel: [ 590.402069] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:43:18 rui kernel: [ 611.040602] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:43:20 rui kernel: [ 613.153379] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:43:41 rui kernel: [ 633.825059] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:43:43 rui kernel: [ 635.936611] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:43:58 rui kernel: [ 650.980297] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:44:01 rui kernel: [ 653.377622] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:44:06 rui kernel: [ 658.918888] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:44:09 rui kernel: [ 661.319139] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:44:24 rui kernel: [ 676.832703] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:44:26 rui kernel: [ 678.944975] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:44:46 rui kernel: [ 698.848483] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:44:48 rui kernel: [ 701.024837] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 08:44:52 rui kernel: [ 705.056365] e1000: eth0 NIC Link is Down Jun 25 08:44:52 rui kernel: [ 705.056391] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 08:44:54 rui kernel: [ 707.174980] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:28:15 rui kernel: [ 3308.128693] e1000: eth0 NIC Link is Down Jun 25 09:28:15 rui kernel: [ 3308.128863] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:28:17 rui kernel: [ 3310.241091] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:28:28 rui kernel: [ 3321.056739] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:28:30 rui kernel: [ 3323.297966] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:28:41 rui kernel: [ 3333.856657] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:28:43 rui kernel: [ 3336.001892] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:29:08 rui kernel: [ 3360.993029] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:29:10 rui kernel: [ 3363.105257] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:29:26 rui kernel: [ 3378.912149] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:29:28 rui kernel: [ 3381.007439] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:29:40 rui kernel: [ 3393.088355] e1000: eth0 NIC Link is Down Jun 25 09:29:40 rui kernel: [ 3393.088381] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:29:42 rui kernel: [ 3395.170789] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:39:25 rui kernel: [ 3978.160481] e1000: eth0 NIC Link is Down Jun 25 09:39:25 rui kernel: [ 3978.160521] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:39:28 rui kernel: [ 3980.353067] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:39:38 rui kernel: [ 3991.008647] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:39:40 rui kernel: [ 3993.184977] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:40:02 rui kernel: [ 4015.073022] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:40:04 rui kernel: [ 4017.249472] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:40:15 rui kernel: [ 4027.872558] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:40:17 rui kernel: [ 4029.956157] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:40:42 rui kernel: [ 4055.008653] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:40:44 rui kernel: [ 4057.091571] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:41:06 rui kernel: [ 4079.074864] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:41:08 rui kernel: [ 4081.191157] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:41:29 rui kernel: [ 4101.856291] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:41:31 rui kernel: [ 4103.968708] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:41:51 rui kernel: [ 4123.872855] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:41:53 rui kernel: [ 4125.985169] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:42:13 rui kernel: [ 4145.888157] e1000 0000:00:03.0 eth0: Reset adapter Jun 25 09:42:15 rui kernel: [ 4147.968831] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX Jun 25 09:43:10 rui kernel: [ 4202.976829] e1000 0000:00:03.0 eth0: Reset adapter
VirtualBox 虛擬機配置參數
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showvminfo 9806a7eb-0045-4373-bf64-1f5d6c895041 Name: Debian Groups: / Guest OS: Debian (64-bit) UUID: 9806a7eb-0045-4373-bf64-1f5d6c895041 Config file: C:\Users\Rui\VirtualBox VMs\Debian\Debian.vbox Snapshot folder: C:\Users\Rui\VirtualBox VMs\Debian\Snapshots Log folder: C:\Users\Rui\VirtualBox VMs\Debian\Logs Hardware UUID: 9806a7eb-0045-4373-bf64-1f5d6c895041 Memory size: 8192MB Page Fusion: off VRAM size: 10MB CPU exec cap: 100% HPET: off Chipset: piix3 Firmware: BIOS Number of CPUs: 2 PAE: on Long Mode: on Triple Fault Reset: off APIC: on X2APIC: on CPUID Portability Level: 0 CPUID overrides: None Boot menu mode: message and menu Boot Device (1): HardDisk Boot Device (2): DVD Boot Device (3): Not Assigned Boot Device (4): Not Assigned ACPI: on IOAPIC: on BIOS APIC mode: APIC Time offset: 0ms RTC: UTC Hardw. virt.ext: on Nested Paging: on Large Pages: on VT-x VPID: on VT-x unr. exec.: on Paravirt. Provider: Default Effective Paravirt. Provider: KVM State: powered off (since 2018-06-27T15:10:06.000000000) Monitor count: 1 3D Acceleration: off 2D Video Acceleration: off Teleporter Enabled: off Teleporter Port: 0 Teleporter Address: Teleporter Password: Tracing Enabled: off Allow Tracing to Access VM: off Tracing Configuration: Autostart Enabled: off Autostart Delay: 0 Default Frontend: Storage Controller Name (0): SATA Storage Controller Type (0): IntelAhci Storage Controller Instance Number (0): 0 Storage Controller Max Port Count (0): 30 Storage Controller Port Count (0): 2 Storage Controller Bootable (0): on Storage Controller Name (1): IDE Storage Controller Type (1): PIIX4 Storage Controller Instance Number (1): 0 Storage Controller Max Port Count (1): 2 Storage Controller Port Count (1): 2 Storage Controller Bootable (1): on SATA (0, 0): C:\Users\Rui\VirtualBox VMs\Debian\Debian.vmdk (UUID: 934dc586-67a5-45c9-b548-90b4f1f7bda0) NIC 1: MAC: 080027F63222, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM , Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none NIC 1 Settings: MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64) NIC 1 Rule(0): name = Rule 1, protocol = tcp, host ip = , host port = 22, guest ip = , guest port = 22 NIC 2: MAC: 080027820F24, Attachment: Host-only Interface 'VirtualBox Host-Only Ethernet Adapter #2', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none NIC 3: disabled NIC 4: disabled NIC 5: disabled NIC 6: disabled NIC 7: disabled NIC 8: disabled Pointing Device: USB Tablet Keyboard Device: PS/2 Keyboard UART 1: disabled UART 2: disabled UART 3: disabled UART 4: disabled LPT 1: disabled LPT 2: disabled Audio: disabled Audio playback: disabled Audio capture: enabled Clipboard Mode: Bidirectional Drag and drop Mode: disabled VRDE: disabled USB: enabled EHCI: disabled XHCI: disabled USB Device Filters: <none> Bandwidth groups: <none> Shared folders: <none> Capturing: not active Capture audio: not active Capture screens: 0 Capture file: C:\Users\Rui\VirtualBox VMs\Debian\Debian.webm Capture dimensions: 1024x768 Capture rate: 512 kbps Capture FPS: 25 Capture options: ac_enabled=false Guest: Configured memory balloon size: 0 MB
虛擬機記憶體使用:
$ free -m total used free shared buff/cache available Mem: 7976 68 7780 2 128 7711 Swap: 2047 0 2047
虛擬機負載:
xxxx@rui:~$ uptime 16:28:27 up 17 min, 1 user, load average: 0,00, 0,00, 0,00
最終,幸運的是,Google搜尋“在 vbox 中隨機失去連接和錯誤,我偶然發現有人建議預設的英特爾**NIC仿真導致不穩定和性能問題。太多隨機的人只是建議在更改預設的英特爾虛擬 NIC 之後否則不穩定就消失了。(遺憾的是,沒有任何建議為什麼會發生這種情況)。
所以我看了一下,你瞧,確實在“VM Virtualbox Manager”界面->VM名稱->設置->網路->高級->適配器類型”中我有預設的虛擬網卡“英特爾Pro 1000 MT桌面( 8254OEM)”。
因此,我關閉了有問題的虛擬機。
知道我已經安裝了 VBox 工具,並藉鑑了我在其他虛擬環境中的經驗,在這些虛擬環境中,半虛擬化 NIC 提供了更高的性能,並且需要更少的 CPU 工作,我從預設的 NIC 類型更改為“半虛擬化網路 (virtio-net)”我使用的兩個介面。
雖然過去 VirtIO 在 VirtualBox 中以有缺陷而聞名,但它似乎在我的測試中表現良好。
路由流量的速度差異非常大,錯誤完全消失了。
PS。我懷疑這是模擬“物理”英特爾 NIC 卡中的 vbox 盒錯誤,與我的真實硬體無關。實際上,我首先更改了 eth0,然後在 eth1 中也開始出現問題,然後兩者都進行了更改。似乎英特爾 VNIC 仿真同時在 eth0 和 eth1 中出現問題。正如我現在在問題中所說,eth1 與物理網卡沒有任何關聯。
PS2。是的,我知道半虛擬化通常會起到推動作用。這裡的核心問題是擺脫嚴重的不穩定性。