Ubuntu 22.04 通过 netplan 配置本地 IP(systemd-networkd)

Ubuntu 22.04 通过 netplan 配置本地 IP(systemd-networkd)

我有一台安装了 Ubuntu 22.04 的服务器,有两个物理网络接口 - eno1 和 eno2,我将这些网络接口配置为网络计划(使用 systemd-networkd)。eno1 已检测到链接,并且配置了 dhcp,eno2 未检测到链接(这没问题),并且配置了本地 IP。

问题:eno2 没有通过 netplan 获取本地 IP 地址。

文件:

cat /etc/netplan/50-eno1.yaml 
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
      dhcp6: false
-----------------------------
cat /etc/netplan/60-eno2.yaml 
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      addresses: [192.168.0.10/24]
      dhcp4: false
      dhcp6: false
      optional: true
-----------------------------
cat /run/systemd/network/10-netplan-eno1.network 
[Match]
Name=eno1

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true
-----------------------------
cat /run/systemd/network/10-netplan-eno2.network 
[Match]
Name=eno2

[Link]
RequiredForOnline=no

[Network]
LinkLocalAddressing=ipv6
Address=192.168.0.10/24

ifconfig:

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 aa::aaa:aaa:aaaa:aaaa  prefixlen 64  scopeid 0x20<link>
        ether bb:bb:bb:bb:bb:bb  txqueuelen 1000  (Ethernet)
        RX packets 1197608  bytes 75258702 (75.2 MB)
        RX errors 0  dropped 84445  overruns 0  frame 0
        TX packets 8120  bytes 1741477 (1.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xbbbbbb-bbbbbb  

eno2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether bb:bb:bb:bb:bb:bb  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x9c900000-9c9fffff  

netplan——调试应用:

** (generate:169153): DEBUG: 09:57:10.149: starting new processing pass
** (generate:169153): DEBUG: 09:57:10.149: starting new processing pass
** (generate:169153): DEBUG: 09:57:10.149: We have some netdefs, pass them through a final round of validation
** (generate:169153): DEBUG: 09:57:10.149: eno2: setting default backend to 1
** (generate:169153): DEBUG: 09:57:10.149: Configuration is valid
** (generate:169153): DEBUG: 09:57:10.149: eno1: setting default backend to 1
** (generate:169153): DEBUG: 09:57:10.149: Configuration is valid
** (generate:169153): DEBUG: 09:57:10.149: Generating output files..
** (generate:169153): DEBUG: 09:57:10.149: openvswitch: definition eno1 is not for us (backend 1)
** (generate:169153): DEBUG: 09:57:10.149: NetworkManager: definition eno1 is not for us (backend 1)
** (generate:169153): DEBUG: 09:57:10.149: openvswitch: definition eno2 is not for us (backend 1)
** (generate:169153): DEBUG: 09:57:10.149: NetworkManager: definition eno2 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, reloading networkd
** (process:169151): DEBUG: 09:57:14.520: starting new processing pass
** (process:169151): DEBUG: 09:57:14.520: starting new processing pass
** (process:169151): DEBUG: 09:57:14.520: We have some netdefs, pass them through a final round of validation
** (process:169151): DEBUG: 09:57:14.520: eno2: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.520: Configuration is valid
** (process:169151): DEBUG: 09:57:14.520: eno1: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.520: Configuration is valid
DEBUG:Merged config:
b''
DEBUG:no netplan generated NM configuration exists
** (process:169151): DEBUG: 09:57:14.527: starting new processing pass
** (process:169151): DEBUG: 09:57:14.527: starting new processing pass
** (process:169151): DEBUG: 09:57:14.527: We have some netdefs, pass them through a final round of validation
** (process:169151): DEBUG: 09:57:14.527: eno2: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.527: Configuration is valid
** (process:169151): DEBUG: 09:57:14.527: eno1: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.527: Configuration is valid
DEBUG:Merged config:
b''
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for eno3
DEBUG:netplan triggering .link rules for eno4
DEBUG:netplan triggering .link rules for eno5
DEBUG:netplan triggering .link rules for eno6
DEBUG:netplan triggering .link rules for eno1
DEBUG:netplan triggering .link rules for eno2
** (process:169151): DEBUG: 09:57:14.673: starting new processing pass
** (process:169151): DEBUG: 09:57:14.673: starting new processing pass
** (process:169151): DEBUG: 09:57:14.673: We have some netdefs, pass them through a final round of validation
** (process:169151): DEBUG: 09:57:14.673: eno2: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.673: Configuration is valid
** (process:169151): DEBUG: 09:57:14.673: eno1: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.673: Configuration is valid
** (process:169151): DEBUG: 09:57:14.673: starting new processing pass
** (process:169151): DEBUG: 09:57:14.673: starting new processing pass
** (process:169151): DEBUG: 09:57:14.673: We have some netdefs, pass them through a final round of validation
** (process:169151): DEBUG: 09:57:14.673: eno2: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.673: Configuration is valid
** (process:169151): DEBUG: 09:57:14.673: eno1: setting default backend to 1
** (process:169151): DEBUG: 09:57:14.673: Configuration is valid
DEBUG:Merged config:
b''

笔记:当我运行ip addr add 192.168.0.10/24 dev eno2它时,它工作正常,我在 eno2 上有一个 IP(可 ping)。但我希望使用 netplan 来实现它。

相关内容