Netplan 问题,无法执行 IP 静态

Netplan 问题,无法执行 IP 静态

我尝试为我的服务器设置两个接口,ubuntu 服务器 18.04,我在局域网中共享互联网,以下是配置

文件 01-netcfg.yaml

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

和 02-netcfg.yaml

 network:
     version: 2
     renderer: networkd
     ethernets:
         enp3s0:
             addresses: [192.168.1.1/24, ]
             dhcp4: false
             dhcp6: false
             nameservers:
                 addresses: [192.168.1.1, 8.8.8.8]

ifconfig 返回

enp3s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 14:cc:20:02:9e:fe  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

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.12  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::e23f:49ff:fe52:22be  prefixlen 64  scopeid 0x20<link>
        ether e0:3f:49:52:22:be  txqueuelen 1000  (Ethernet)
        RX packets 3154  bytes 479397 (479.3 KB)
        RX errors 0  dropped 48  overruns 0  frame 0
        TX packets 199  bytes 28954 (28.9 KB)
        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 308  bytes 21480 (21.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 308  bytes 21480 (21.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这是 netplan apply 命令

netplan --debug apply
** (generate:2734): DEBUG: 14:28:02.178: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:2734): DEBUG: 14:28:02.178: starting new processing pass
** (generate:2734): DEBUG: 14:28:02.179: Processing input file /etc/netplan/02-netcfg.yaml..
** (generate:2734): DEBUG: 14:28:02.179: starting new processing pass
** (generate:2734): DEBUG: 14:28:02.179: enp3s0: setting default backend to 1
** (generate:2734): DEBUG: 14:28:02.179: Configuration is valid
** (generate:2734): DEBUG: 14:28:02.179: enp4s0: setting default backend to 1
** (generate:2734): DEBUG: 14:28:02.179: Configuration is valid
** (generate:2734): DEBUG: 14:28:02.179: Generating output files..
** (generate:2734): DEBUG: 14:28:02.179: NetworkManager: definition enp4s0 is not for us (backend 1)
** (generate:2734): DEBUG: 14:28:02.179: NetworkManager: definition enp3s0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:enp4s0 not found in {}
DEBUG:enp3s0 not found in {'enp4s0': {'dhcp4': True}}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets:
    enp3s0:
      addresses:
      - 192.168.1.1/24
      dhcp4: false
      dhcp6: false
      nameservers:
        addresses:
        - 192.168.1.1
        - 8.8.8.8
    enp4s0:
      dhcp4: true
  vlans: {}
  wifis: {}

DEBUG:Skipping non-physical interface: lo
DEBUG:device enp4s0 operstate is up, not changing
DEBUG:Skipping non-physical interface: tap0
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp3s0
DEBUG:netplan triggering .link rules for enp4s0
DEBUG:netplan triggering .link rules for tap0

我不知道为什么我无法设置 IP 地址,请问有人能帮帮我吗?

答案1

问题是,当电缆拔掉时,netplan 从不进行配置,而是等待插入。就是这样,感谢您的阅读

相关内容