自定义网络接口不可见

自定义网络接口不可见

我正在学习 Linux 上的网络。我在 VirtualBox 上启动了 Ubuntu Server 22,但不幸的是我遇到了问题。确切地说,我想添加一个具有静态 IP 的新网络接口,我将接口添加到 netplan,但重新启动系统后我的接口消失了,并且 netplan apply 没有显示任何错误

默认网络接口

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: true
  version: 2

我的自定义界面

network:
    ethernets:
        enp0s5:
            dhcp4: false
            addresses: [192.168.2.202/24]
            routes:
              - to: default
                via: 192.168.2.1
            nameservers:
              addresses: [8.8.8.8,8.8.4.4]
    version: 2

netplan --debug 应用结果

pawel@local:/var/log$ sudo netplan --debug apply
** (generate:1194): DEBUG: 17:14:59.302: starting new processing pass
** (generate:1194): DEBUG: 17:14:59.302: starting new processing pass
** (generate:1194): DEBUG: 17:14:59.302: enp0s5: adding new route
** (generate:1194): DEBUG: 17:14:59.303: We have some netdefs, pass them through a final round of validation
** (generate:1194): DEBUG: 17:14:59.303: enp0s3: setting default backend to 1
** (generate:1194): DEBUG: 17:14:59.303: Configuration is valid
** (generate:1194): DEBUG: 17:14:59.304: enp0s5: setting default backend to 1
** (generate:1194): DEBUG: 17:14:59.304: Configuration is valid
** (generate:1194): DEBUG: 17:14:59.305: Generating output files..
** (generate:1194): DEBUG: 17:14:59.305: Open vSwitch: definition enp0s3 is not for us (backend 1)
** (generate:1194): DEBUG: 17:14:59.305: NetworkManager: definition enp0s3 is not for us (backend 1)
** (generate:1194): DEBUG: 17:14:59.306: Open vSwitch: definition enp0s5 is not for us (backend 1)
** (generate:1194): DEBUG: 17:14:59.306: NetworkManager: definition enp0s5 is not for us (backend 1)
** (process:1192): DEBUG: 17:14:59.696: starting new processing pass
** (process:1192): DEBUG: 17:14:59.696: starting new processing pass
** (process:1192): DEBUG: 17:14:59.696: enp0s5: adding new route
** (process:1192): DEBUG: 17:14:59.696: We have some netdefs, pass them through a final round of validation
** (process:1192): DEBUG: 17:14:59.696: enp0s3: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.696: Configuration is valid
** (process:1192): DEBUG: 17:14:59.696: enp0s5: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.696: Configuration is valid
** (process:1192): DEBUG: 17:14:59.744: starting new processing pass
** (process:1192): DEBUG: 17:14:59.744: starting new processing pass
** (process:1192): DEBUG: 17:14:59.744: enp0s5: adding new route
** (process:1192): DEBUG: 17:14:59.744: We have some netdefs, pass them through a final round of validation
** (process:1192): DEBUG: 17:14:59.744: enp0s3: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.744: Configuration is valid
** (process:1192): DEBUG: 17:14:59.744: enp0s5: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.744: Configuration is valid
** (process:1192): DEBUG: 17:14:59.843: starting new processing pass
** (process:1192): DEBUG: 17:14:59.843: starting new processing pass
** (process:1192): DEBUG: 17:14:59.844: enp0s5: adding new route
** (process:1192): DEBUG: 17:14:59.844: We have some netdefs, pass them through a final round of validation
** (process:1192): DEBUG: 17:14:59.844: enp0s3: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.844: Configuration is valid
** (process:1192): DEBUG: 17:14:59.844: enp0s5: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.844: Configuration is valid
** (process:1192): DEBUG: 17:14:59.844: starting new processing pass
** (process:1192): DEBUG: 17:14:59.844: starting new processing pass
** (process:1192): DEBUG: 17:14:59.844: enp0s5: adding new route
** (process:1192): DEBUG: 17:14:59.844: We have some netdefs, pass them through a final round of validation
** (process:1192): DEBUG: 17:14:59.844: enp0s3: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.844: Configuration is valid
** (process:1192): DEBUG: 17:14:59.844: enp0s5: setting default backend to 1
** (process:1192): DEBUG: 17:14:59.844: Configuration is valid

但是 ifconfig 只显示一个接口,没有我的自定义

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.43  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::a00:27ff:fe7c:8fb6  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:7c:8f:b6  txqueuelen 1000  (Ethernet)
        RX packets 1510  bytes 118670 (118.6 KB)
        RX errors 0  dropped 39  overruns 0  frame 0
        TX packets 1982  bytes 1105945 (1.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 84  bytes 6308 (6.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 6308 (6.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

为什么我的自定义接口不起作用?我做错了什么?

相关内容