大网数据广告活动
服务器运维问答

netplan apply/try/generate ends with ERROR

· 52CE 我爱测

We have cloud infrastructure based on VMWare with Windows and Linux VMs. After last reboot 4 of the Ubuntu (3 Ubuntu 20.04 and one Ubuntu 16.04) servers did not start network interface. With lshw -class network I see correct netw…

问题原文

原帖链接 · Karlis · CC BY-SA 4.0

We have cloud infrastructure based on VMWare with Windows and Linux VMs. After last reboot 4 of the Ubuntu (3 Ubuntu 20.04 and one Ubuntu 16.04) servers did not start network interface. With lshw -class network I see correct network interface listed. There is no DHCP in the network, all servers use static IP's. After reboot in networkctl OPERATIONAL column for the specific interface is OFF. Only way to get network working is with following IP command sequence, but after reboot everything is gone:

$ip link set <link_name> up
$ip addr add <server-ip>/24 dev <link_name>
$ip route add default via <gateway> dev <link_name>

Looks like the problem is with netplan. I have netplan config, that is deployed together with server, when created from template and it works great on all the other Ubuntu servers in this infrastructure except those 4 servers. Also it worked on those servers until this weeks reboot (we update and reboot once a month usually) Config looks like this:

network:
  version: 2
  renderer: networkd
  ethernets:
    <link_name>:
      dhcp4: no
      dhcp6: no
      addresses:
        - <server_ip>/24
      gateway4: <gateway>
      nameservers:
        search:
          - <domain>
        addresses:
          - <dns_1>
          - <dns_2>

But when trying to netplan apply , netplan generate or netplan try, it returns strange ERROR, I cant find anything about in the internet.( I substituted my gateway IP with <correct_gateway> and the other IP in this operations with <some_random_ip> for security purposes)

ERROR:src/parse.c:1120:handle_gateway4: assertion failed (scalar(node) == cur_netdef->gateway4): ("<correct_gateway>" == "<some_random_ip>")
Bail out! ERROR:src/parse.c:1120:handle_gateway4: assertion failed (scalar(node) == cur_netdef->gateway4): ("<correct_gateway>" == "<some_random_ip>")

If I add some indentation mistake in *.yaml config file it returns normal Error message that points to this mistake.

I tried to reinstall netplan.io without any luck and don't have an idea what to try next.

已采纳解答

原帖链接 · Karlis · CC BY-SA 4.0

Well, found solution.

The problem was depreciated gateway4 tag in configuration file.

What was gateway4: <gateway> , now is:

      routes:
      - to: default
        via: <gateway>
        metric: 100

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-12-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。