canonical / canonical/cloud-init

Setting an IPv6 default route using "::/0" in network-config doesn't render correctly on non-netplan systems

Open
#4,600 1 comment 0 reactions 0 assignees View on GitHub
bug priority
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
Attempting to set IPv6 default route using "to: ::/0" under the "routes" section in the network-config. However, cloud-init instead configures a route to "::/64" on non-netplan systems.

## Steps to reproduce the problem
cloud-init yaml file to configure the network:
```
network:
version: 2
ethernets:
ens192:
addresses:
- 10.0.0.2/24
- 2001:db8:1::2/64
routes:
- to: 0.0.0.0/0
via: 10.0.0.1
- to: ::/0
via: 2001:db8:1::1
```

#### DEBIAN TEST
cloud-init command to convert input yaml into Debian network configuration file:
`cloud-init devel net-convert -p net.yaml -k yaml --output-kind eni -d out -D debian --debug`

/etc/network/interfaces.d/50-cloud-init:
```
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback

auto ens192
iface ens192 inet static
address 10.0.0.2/24
post-up route add default gw 10.0.0.1 || true
pre-down route del default gw 10.0.0.1 || true
post-up route add -A inet6 ::/64 gw 2001:db8:1::1 || true
pre-down route del -A inet6 ::/64 gw 2001:db8:1::1 || true

# control-alias ens192
iface ens192 inet6 static
address 2001:db8:1::2/64
```

#### ALMALINUX TEST
cloud-init command to convert input yaml into AlmaLinux network configuration file:
`cloud-init devel net-convert -p net.yaml -k yaml --output-kind sysconfig -d out -D almalinux --debug`

/etc/sysconfig/network-scripts/route6-ens192:
```
# Created by cloud-init on instance boot automatically, do not edit.
#
::/64 via 2001:db8:1::1 dev ens192
```

## Environment details
- Cloud-init version: 22.4.2
- Operating System Distribution: Debian & AlmaLinux

## More info
It is possible to set the default route using the gateway4 and gateway6 properties, but those are deprecated in Netplan in favour of using the "routes" section. We would like to use a consistent cloud-init network-config regardless of OS distribution (ubuntu / debian / almalinux) so that is why we are specifically trying to set the gateway using the "routes" section in these examples.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.