Ubuntu Netplan – Fixing Apply/Try/Generate Errors

netplanUbuntu

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.

Best Answer

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
Related Topic