Address default is not a valid ip network

Bug #1989289 reported by Christian Dohm
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
Invalid
Undecided
Unassigned
cloud-init (Ubuntu)
New
Undecided
Unassigned

Bug Description

I'm setting up a Raspberry Pi 4B with the newest Ubuntu 22.04.1 LTS Server image for arm64, as delivered by the rpi-imager v1.7.2, via cloud-init facilities.

On first and all subsequent system startups, configuring the network fails with the following error message in "/var/log/cloud-init-output.log":
---
Cloud-init v. 22.2-0ubuntu1~22.04.3 running 'init-local' at Sun, 11 Sep 2022 17:44:58 +0000. Up 13.83 seconds.
2022-09-11 17:44:58,854 - network_state.py[ERROR]: Address default is not a valid ip network
2022-09-11 17:44:58,854 - util.py[WARNING]: failed stage init-local
failed run of stage init-local
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 740, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 410, in main_init
    init.apply_network_config(bring_up=bring_up_interfaces)
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 937, in apply_network_config
    return self.distro.apply_network_config(
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 231, in apply_network_config
    network_state = parse_net_config_data(netconfig)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 1056, in parse_net_config_data
    nsi.parse_config(skip_broken=skip_broken)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 278, in parse_config
    self.parse_config_v2(skip_broken=skip_broken)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 327, in parse_config_v2
    handler(self, command)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 720, in handle_ethernets
    subnets = self._v2_to_v1_ipcfg(cfg)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 880, in _v2_to_v1_ipcfg
    _normalize_route(
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 1019, in _normalize_route
    _normalize_net_keys(
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 953, in _normalize_net_keys
    raise ValueError(f"Address {addr} is not a valid ip address")
ValueError: Address default is not a valid ip address
------------------------------------------------------------
Cloud-init v. 22.2-0ubuntu1~22.04.3 running 'init' at Sun, 11 Sep 2022 17:45:00 +0000. Up 15.80 seconds.
ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: | eth0 | False | . | . | . | <lan-mac-address> |
ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
ci-info: | lo | True | ::1/128 | . | host | . |
ci-info: | wlan0 | False | . | . | . | <wifi-mac-addrss> |
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: | Route | Destination | Gateway | Interface | Flags |
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: +-------+-------------+---------+-----------+-------+
---

The contents of "/boot/network-config" were generated with Terraform's yamlencode() function:
---
version: 2
"ethernets":
  "eth0":
    "addresses":
    - "<ipv4-classc-ip>/24"
    - "<ipv6ll-address>/64"
    "dhcp4": false
    "dhcp6": false
    "match":
      "driver":
      - "bcmgenet"
      - "smsc95xx"
      - "lan78xx"
    "nameservers":
      "addresses":
      - "<ipv4-gw-address>"
      "search":
      - "<some.domain>"
    "routes":
    - "to": "default"
      "via": "<ipv4-gw-address>"
    "set-name": "eth0"
---

Tags: default routes
Revision history for this message
Christian Dohm (chris1294832) wrote :

Interestingly, when the string "default" is changed to "0/0", the message becomes

---
Cloud-init v. 22.2-0ubuntu1~22.04.3 running 'init-local' at Tue, 09 Aug 2022 12:05:25 +0000. Up 12.50 seconds.
2022-08-09 12:05:26,677 - network_state.py[ERROR]: Address 0/0 is not a valid ip network
2022-08-09 12:05:26,679 - util.py[WARNING]: failed stage init-local
failed run of stage init-local
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 740, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 410, in main_init
    init.apply_network_config(bring_up=bring_up_interfaces)
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 937, in apply_network_config
    return self.distro.apply_network_config(
  File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 231, in apply_network_config
    network_state = parse_net_config_data(netconfig)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 1056, in parse_net_config_data
    nsi.parse_config(skip_broken=skip_broken)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 278, in parse_config
    self.parse_config_v2(skip_broken=skip_broken)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 327, in parse_config_v2
    handler(self, command)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 720, in handle_ethernets
    subnets = self._v2_to_v1_ipcfg(cfg)
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 880, in _v2_to_v1_ipcfg
    _normalize_route(
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 1019, in _normalize_route
    _normalize_net_keys(
  File "/usr/lib/python3/dist-packages/cloudinit/net/network_state.py", line 953, in _normalize_net_keys
    raise ValueError(f"Address {addr} is not a valid ip address")
ValueError: Address 0/0 is not a valid ip address
------------------------------------------------------------
---

Revision history for this message
Christian Dohm (chris1294832) wrote :

It does indeed work as expected when the 'to' field is set to "0.0.0.0/0".

description: updated
Simon Chopin (schopin)
Changed in netplan:
status: New → Invalid
Revision history for this message
Simon Chopin (schopin) wrote :

The "default" value as a valid route destination has been added to netplan a year ago as part of the deprecation of the gateway[46] fields: https://github.com/canonical/netplan/pull/216

The issue seems to be that cloud-init, which also parses a subset of the network config format, hasn't picked up this modification. Thus, the bug isn't in netplan per se.

I'm a bit surprised though, as I thought the cloud-init network config parser wasn't used if netplan was available on the system?

Revision history for this message
James Falcon (falcojr) wrote (last edit ):

Until recently, cloud-init would still parse the v2 config to ensure it's valid before passing it on to netplan. This was recently fixed in https://github.com/canonical/cloud-init/pull/1650 and will be available in cloud-init 22.3.1.

This bug is also a duplicate, so I will be marking it as such.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.