每次重启后,虚拟 Ubuntu 18.04 中的 USB 以太网接口都会被禁用

每次重启后,虚拟 Ubuntu 18.04 中的 USB 以太网接口都会被禁用

(tl;dr) 我的 USB 3.0 以太网适配器被找到(lsusb),但是在 Ubuntu 18.04 beta 2 中每次重启后以太网接口都会被禁用,即使我使用ipifconfig命令启用它(有趣的是:它在安装过程中被发现甚至通过 dhcp 连接,但在第一次重启后被禁用)。

详细版本:我正在尝试让 DELOCK 62966 USB 3.0 > 4x 以太网适配器在 Ubuntu 机器中工作。重要提示:Ubuntu 在最新的 Virtualbox 中作为 VM 运行,带有允许从 VM 访问的 USB 过滤器。它在并行运行的 Windows VM 中运行良好。我还尝试了不同的适配器(Lenovo Thinkpad USB 3.0 以太网适配器)。

sudo lshw -C network得出以下结果:

*-network DISABLED
description: Ethernet interface
physical id: 1
logical name: enx00e04c6801e1
[...]

我尝试了过去 10 年中多个论坛提供的解决方案,例如:

sudo ip link set enx00e04c6801e1 up
sudo ip l s dev enx00e04c6801e1 up

这导致sudo lshw -C network不再显示“已禁用”,但ifconfig显示接口没有有效的 IP。所以我使用了sudo dhclient enx00e04c6801e1。然后,它终于显示了一个有效的 IP 地址。

仅供参考,我的电脑/etc/network/interfaces完全是空的。我尝试添加以下几行,但没有任何效果(我尝试/重启了多次)

auto lo
iface lo inet loopback
auto enx00e04c6801e1
iface enx00e04c6801e1 inet dhcp

我是否必须在启动时启动的脚本中添加所有这些步骤(如果是的话如何做?)或者是否有一个简单的解决方案来告诉 ubuntu 每次启动时使用适配器?

感谢您的帮助!!

更新 1:结果如下cat /etc/netplan/*.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp0s3:
            addresses: []
            dhcp4: true
    version: 2

-> 是不是意味着我也需要添加 enx...?

答案1

根据错误报告,解决方案是将缺少的配置文件(/etc/NetworkManager/conf.d/10-globally-managed-devices.conf)添加到NetworkManager,然后重新启动。

sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
sudo reboot

答案2

在戴尔电脑上,内部以太网可以正常工作,但我安装的 PCI 和 PCIe 卡(Rosewill/RealTek)会显示为DISABLEDlshw -c network即使我启用了它们,它们在重启后也无法恢复。

以下是我在 ubuntu 18.04LTS 服务器(无 GUI)上的工作方式:

我备份了/etc/netplan/01-netcfg.yaml

cp 01-netcfg.yaml 01-netcfg.yaml_180504_1232

我编辑了以下内容/etc/netplan/01-netcfg.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s25:
      dhcp4: yes

至 (使用logical name:来自lshw -c network):

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: yes
    enp3s0:
      dhcp4: yes
    enp0s25:
      dhcp4: yes

应用更改:

netplan --debug apply
** (generate:2169): DEBUG: 12:36:12.418: Processing input file //etc/netplan/01-netcfg.yaml..
** (generate:2169): DEBUG: 12:36:12.418: starting new processing pass
** (generate:2169): DEBUG: 12:36:12.418: enp3s0: setting default backend to 1
** (generate:2169): DEBUG: 12:36:12.418: enp0s25: setting default backend to 1
** (generate:2169): DEBUG: 12:36:12.418: enp1s0: setting default backend to 1
** (generate:2169): DEBUG: 12:36:12.418: Generating output files..
** (generate:2169): DEBUG: 12:36:12.418: NetworkManager: definition enp3s0 is not for us (backend 1)
** (generate:2169): DEBUG: 12:36:12.418: NetworkManager: definition enp0s25 is not for us (backend 1)
** (generate:2169): DEBUG: 12:36:12.418: NetworkManager: definition enp1s0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:replug enp1s0: unbinding 0000:01:00.0 from /sys/bus/pci/drivers/r8169
DEBUG:replug enp1s0: rebinding 0000:01:00.0 to /sys/bus/pci/drivers/r8169
DEBUG:device enp0s25 operstate is up, not replugging
DEBUG:netplan triggering .link rules for enp0s25
DEBUG:device lo operstate is unknown, not replugging
DEBUG:netplan triggering .link rules for lo
DEBUG:replug enp3s0: unbinding 0000:03:00.0 from /sys/bus/pci/drivers/r8169
DEBUG:replug enp3s0: rebinding 0000:03:00.0 to /sys/bus/pci/drivers/r8169

感谢这些页面为我指明了方向:

  1. https://arador.com/how-to-configure-a-static-ip-address-in-ubuntu-18-04/
  2. https://ppc64el.wordpress.com/2018/03/22/ubuntu-18-04-netplan/(小心这一点,因为它没有显示缩进,这在 yaml 中当然是至关重要的)

相关内容