cloud-init should officially support routes with source ip
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
cloud-init supports routes with source IPs on netplan systems (because it passes the configuration through to netplan). It does not support this on non-netplan systems, because renderer support has not been written.
[Original Report]
https:/
the following example currently works but it's not documented at this time.
version: 2
renderer: networkd
ethernets:
ens18:
addresses:
- 10.0.0.1/24
- 10.0.0.2/24
routes:
- to: 10.0.1.0/24
via: 10.0.0.3
from: 10.0.0.1
- to: 10.0.2.0/24
via: 10.0.0.4
from: 10.0.0.2
Changed in cloud-init: | |
status: | Triaged → Fix Released |
Hi Richard,
Thanks for using cloud-init and for the bug report!
cloud-init passes through the v2 format to netplan (when present, i.e. on Ubuntu), or else it converts it to the appropriate format for the current system (sysconfig, ENI or *BSD). Those backends (or our renderers for them) do not necessarily have support for everything that netplan supports, which is why that doc says:
> Cloud-init’s support for Version 2 network config is a subset of the version 2 format defined for the netplan tool.
So it's possible that you could see this working on a netplan-enabled system because of the passthrough, but that doesn't necessarily mean that it should be listed in our documentation.
I believe the relevant lines of code are https:/ /github. com/canonical/ cloud-init/ blob/5d017ab6d1 368271f4a522a24 e16e57fbbd6e53a /cloudinit/ net/network_ state.py# L808-L810, in `_v2_to_v1_ipcfg`:
for route in cfg.get('routes', []): append( _normalize_ route(
{'destinatio n': route.get('to'), 'gateway': route.get('via')}))
routes.
Here we can see that `from` is not pulled out of the route definition; I believe this implies that it won't be available to the non-passthrough renderers, and so can't possibly be supported by them.
So: I agree that it would be good for cloud-init to support routes with source IPs but, unfortunately, that's a feature request and not merely a documentation bug. (Though perhaps we could clarify the language at the top of that doc to make it clearer why this does work on Ubuntu?)
(If you're seeing this work on a non-netplan system then I've evidently got the wrong end of the stick: let me know and I'll take another look. :)
Thanks!
Dan