Systemd-networkd generated configuration is wrong when both ipv4 and ipv6 addresses are used
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
High
|
Alberto Contreras |
Bug Description
Hello,
I'm using cloud-init in a proxmox environment, which exposes the configuration as a /dev/sr0.
The generated network-config looks like this:
```
[root@newgate:~]# more /mnt/*|cat
::::::::::::::
/mnt/meta-data
::::::::::::::
instance-id: 550761acf2ff3ad
::::::::::::::
/mnt/network-config
::::::::::::::
version: 1
config:
- type: physical
name: eth0
mac_address: 'ae:98:25:fa:36:9e'
subnets:
- type: static
address: '10.0.0.2'
netmask: '255.255.255.255'
gateway: '10.0.0.1'
- type: static6
address: '2a01:4f8:
gateway: '2a01:4f8:
- type: nameserver
address:
- '100.100.100.100'
search:
- 'rgrunbla.
::::::::::::::
/mnt/user-data
::::::::::::::
#cloud-config
hostname: newgate
manage_etc_hosts: true
ssh_authorized_
- ssh-ed25519 AAAAC3NzaC1lZDI
chpasswd:
expire: False
users:
- default
package_upgrade: true
::::::::::::::
/mnt/vendor-data
::::::::::::::
```
The problem is that the generated systemd-networkd configuration is wrong. It looks like this:
```
[root@newgate:~]# cat /etc/systemd/
[Match]
MACAddress=
Name=eth0
[Network]
DHCP=no
DNS=100.100.100.100
Domains=
[Address]
Address=10.0.0.2/32
Address=
[Route]
Gateway=10.0.0.1
Gateway=
```
In particular, the systemd-networkd manual says: "As in the [Network] section. This setting is mandatory. Each [Address] section can contain one Address= setting".
This results in errors in systemd:
```
[root@newgate:~]# systemctl status systemd-networkd --no-pager --all
● systemd-
Loaded: loaded (/etc/systemd/
Drop-In: /nix/store/
Active: active (running) since Tue 2022-05-17 07:46:48 UTC; 5min ago
TriggeredBy: ● systemd-
Docs: man:systemd-
Main PID: 643 (systemd-network)
Status: "Processing requests..."
IP: 0B in, 392B out
IO: 1.6M read, 0B written
Tasks: 1 (limit: 2354)
Memory: 2.9M
CPU: 25ms
CGroup: /system.
└─643 /nix/store/
May 17 07:46:48 newgate systemd[1]: Starting Network Configuration...
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd[1]: Started Network Configuration.
May 17 07:46:48 newgate systemd-
May 17 07:46:48 newgate systemd-
May 17 07:46:49 newgate systemd-
```
Changed in cloud-init: | |
assignee: | nobody → Alberto Contreras (aciba) |
Thanks for the background and analysis and making cloud-init better.
I can confirm the failure using the following steps:
cat > net.cfg <<EOF 10a:19d2: :4/64' 10a:19d2: :2' github. beta.tailscale. net'
version: 1
config:
- type: physical
name: eth0
mac_address: 'ae:98:25:fa:36:9e'
subnets:
- type: static
address: '10.0.0.2'
netmask: '255.255.255.255'
gateway: '10.0.0.1'
- type: static6
address: '2a01:4f8:
gateway: '2a01:4f8:
- type: nameserver
address:
- '100.100.100.100'
search:
- 'rgrunbla.
EOF
cloud-init devel net-convert -k yaml -p net.cfg -O networkd -d data -D ubuntu systemd/ network/ 10-cloud- init-eth0. network network/ 10-cloud- init-eth0. network 00:16:3e: 76:25:ac
cat data/etc/
etc/systemd/
[Match]
MACAddress=
Name=eth0
[Network] rgrunbla. github. beta.tailscale. net
DHCP=no
DNS=100.100.100.100
Domains=
[Address] 2a01:4f8: 10a:19d2: :4/64
Address=10.0.0.2/32
Address=
[Route] 2a01:4f8: 10a:19d2: :2
Gateway=10.0.0.1
Gateway=
cp etc/systemd/ network/ 10-cloud- init-eth0. network /lib/systemd/ networkd
sudo service systemd-networkd restart networkd[ 769]: /lib/systemd/ network/ 10-cloud- init networkd[ 769]: eth0: IPv6 successfully enabled networkd[ 769]: eth0: Gained IPv6LL networkd[ 769]: Enumeration completed networkd[ 769]: eth0: Could not set route: No rout networkd[ 769]: eth0: Configured
sudo service systemd-networkd status
..
May 19 20:04:06 dev-bb systemd[1]: Starting Network Service...
May 19 20:04:06 dev-bb systemd-
May 19 20:04:06 dev-bb systemd-
May 19 20:04:06 dev-bb systemd-
May 19 20:04:06 dev-bb systemd-
May 19 20:04:06 dev-bb systemd[1]: Started Network Service.
May 19 20:04:06 dev-bb systemd-
May 19 20:04:06 dev-bb systemd-
lines 1-18/18 (END)
```