我在 VirtualBox 中使用 Debian Buster VM 作为我的 Windows 10 笔记本电脑的路由器。 [这里不值得一提的原因]
几天来它运行良好,但昨天和今天,在我家里相对稳定的网络中,流量变得异常缓慢且不可靠。包括主机在内的其他设备均工作正常。重新启动虚拟机(并且仅虚拟机)可以暂时修复该问题,但很快问题就会再次出现。
经过仔细检查,我在控制台和/var/log/syslog
.
我的 eth0 和 eth1 接口出现类似的问题/错误,它们是虚拟网络接口卡。
真实设备主机是配备 Intel 双频 Wireless-AC 3165 的 Lenovo ThinkPad E560 Intel i7,它是 eth0 NAT 背后的真实 NIC。
但是,eth1 是内部网络的虚拟网络接口,它只与 Windows 主机上的另一个虚拟网络接口通信,并且与实际网络接口卡或外部流量没有任何关联。因此,问题似乎与(外部/实际)网络或主机的物理接口无关。
Virtual Box 版本为 5.2.12 r122591 (Qt5.6.2)。我还在相关虚拟机中安装了 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
相关虚拟机的输出。
$ 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
答案1
最终,幸运的是,在谷歌上搜索“vbox 中随机失去连接和错误”,我偶然发现人们建议默认Intel NIC 仿真导致不稳定和性能问题。太多随机人只建议更改默认的英特尔虚拟网卡后为了别的事不稳定的情况消失了。 (遗憾的是没有任何建议为什么会发生这种情况)。
所以我看了一下,你瞧,确实在“VM Virtualbox Manager”界面->VM名称->设置->网络->高级->适配器类型”中我有默认值虚拟的网卡“Intel Pro 1000 MT 桌面 (8254OEM)”。
因此,我关闭了有问题的虚拟机。
知道我已经安装了 VBox 工具,并根据我在其他虚拟环境中的经验,其中半虚拟化 NIC 提供了更高的性能,并且需要更少的 CPU 工作,我将默认的 NIC 类型更改为“半虚拟化网络 (virtio-net)”我使用的两个接口。
虽然过去 VirtIO 在 VirtualBox 中因存在缺陷而闻名,但在我的测试中,它似乎表现良好。
路由流量的速度差异非常大,并且错误完全消失。
附言。我怀疑这是“物理”Intel NIC 卡模拟中的 vbox 错误,与我的真实硬件无关。实际上我先更改了 eth0,然后 eth1 也开始出现问题,然后又更改了两者。看来 Intel VNIC 模拟同时在 eth0 和 eth1 中出现问题。正如我在问题中所说现在,eth1 与物理 NIC 没有任何关联。
PS2。是的,我知道半虚拟化通常会带来推动作用。这里的核心问题是摆脱严重的不稳定因素。