如何在 Ubuntu 20.04 上使用 netplan 恢复正常工作的网络配置

如何在 Ubuntu 20.04 上使用 netplan 恢复正常工作的网络配置

最近我尝试安装 open nebula,出于某种原因,eno1 网络接口从我的 Ubuntu 20.04 网络配置中消失了,我想恢复它,因为我现在无法连接到互联网。Ubuntu 20.04 使用 netplan。这是我的01-network-manager-all.yaml文件:

network:

version: 2

renderer: networkd

ethernets:

eno1:

dhcp4: true

当我这样做时ifconfig,我看到了这些网络接口:

docker0 : inet 172.17.0.1 ; netmask 255.255.0.0 ; broadcast 172.17.255.255

minione-nic : no inet ; no netmask ; no broadcast

veth03ad024 : no inet ; no netmask ; no broadcast

virbr0 : inet 192.168.122.1 ; netmask 255.255.255.0 ; broadcast 192.168.122.255

virbr0-nic : no inet ; no netmask ; no broadcast ;

我尝试使用以下命令重新创建旧的 eno1 接口:

sudo netman apply

sudo systemctl restart network-manager

我没有看到任何识别错误,但情况没有改变。我没有 eno1 接口,也没有连接到互联网。我该怎么办?缺少什么?

注意:这是按照@heynnema 的原始建议后发生的情况:

root@ziomario-I5:/etc/netplan# sudo netplan --debug generate

DEBUG:command generate: running ['/lib/netplan/generate']

** (generate:3712): DEBUG: 22:35:25.392: Processing input file 
/etc/netplan/01-network-manager-all.yaml..

** (generate:3712): DEBUG: 22:35:25.392: starting new processing pass

** (generate:3712): DEBUG: 22:35:25.393: We have some netdefs, pass them 

through a final round of validation

** (generate:3712): DEBUG: 22:35:25.393: eno1: setting default backend to 

2

** (generate:3712): DEBUG: 22:35:25.393: Configuration is valid

** (generate:3712): DEBUG: 22:35:25.393: Generating output files..

** (generate:3712): DEBUG: 22:35:25.393: networkd: definition eno1 is not 

for us (backend 2)

(generate:3712): GLib-DEBUG: 22:35:25.393: posix_spawn avoided (fd close 

requested) 

这是我使用的 netplan 文件 (01-network-manager-all.yaml):

# Let NetworkManager manage all devices on this system

network:

  version: 2

  renderer: NetworkManager

  ethernets:

    eno1:

      dhcp4: true

我也尝试过这个版本:

# Let NetworkManager manage all devices on this system

network:

  version: 2

  renderer: NetworkManager

我也尝试过:

# Let NetworkManager manage all devices on this system

network:

  version: 2

  renderer: networkd

  ethernets:

    eno1:

      dhcp4: true

它说: NetworkManager : definition eno1 is not for us (backend 1

没有产生eno1接口。所以它不起作用。

root@ziomario-I5:/etc/netplan# sudo lshw -C network

  *-network UNCLAIMED       
       description: Ethernet controller
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:03:00.0
       version: 06
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list
       configuration: latency=0
       resources: ioport:d000(size=256) memory:d3804000-d3804fff memory:d3800000-d3803fff
  *-network:0
       description: Ethernet interface
       physical id: 2
       logical name: veth91a709d
       serial: 96:ae:1d:67:88:d8
       size: 10Gbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
  *-network:1
       description: Ethernet interface
       physical id: 3
       logical name: docker0
       serial: 02:42:22:9d:a2:14
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=yes multicast=yes
  *-network:2
       description: Ethernet interface
       physical id: 4
       logical name: virbr0
       serial: 52:54:00:6b:98:0e
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=192.168.122.1 link=no multicast=yes
  *-network:3 DISABLED
       description: Ethernet interface
       physical id: 5
       logical name: virbr0-nic
       serial: 52:54:00:6b:98:0e
       size: 10Mbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=tun driverversion=1.6 duplex=full link=no multicast=yes port=twisted pair speed=10Mbit/s

netplan 配置

我的 /etc/network/interfaces 文件看起来像这样...

interfaces(5) file used by ifup(8) and ifdown(8)

auto lo
iface lo inet loopback

dkms status

bbswitch 0.8 ; 5.4.0-40-generic, x86_64 : installed
bbswitch 0.8 ; 5.4.0-41-generic, x86_64 : installed
bbswitch 0.8 ; 5.4.0-42-generic, x86_64 : installed
virtualbox,6.1.10, 5.4.0-40-generic, x86_64 : installed
virtualbox,6.1.10, 5.4.0-41-generic, x86_64 : installed 
virtualbox,6.1.10, 5.4.0-42-generic, x86_64 : installed

部分解决方案:RTL8111/8168/8411 PCI Express 千兆以太网控制器无法与内核 5.4.0-42-generic 配合使用;它提示设备未被认领。相反,在内核 5.4.0-41-generic 中,它可以完美运行。所以这是该内核版本的一个错误。

答案1

编辑您的/etc/netplan/01-network-manager-all.yaml内容。保留间距、缩进,并且不使用制表符,与我展示的完全一样。


对于服务器或 systemd-networkd:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true

对于桌面和 NetworkManager:

network:
  version: 2
  renderer: NetworkManager

sudo netplan --debug generate

sudo netplan apply

reboot

更新#1:

我已经加载了 Ubuntu Live 并且看到了 eth0 接口并且它可以正常工作。

更新 #2:

RTL8111/8168/8411 PCI Express 千兆以太网控制器无法与内核 5.4.0-42-generic 配合使用;它提示设备未被认领。相反,在内核 5.4.0-41-generic 中,它可以完美运行。所以这是该内核版本的一个错误。

更新 #3:

安装了r8168-dkms驱动程序,它与内核 5.4.0-42-generic 一起工作。

请注意,-41 内核和损坏的 -42 内核均来自启用Proposed存储库。我建议禁用该存储库。

相关内容