canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.87k stars 856 forks source link

On SUSE mixed static and dhcp setups are no properly configured #3526

Open ubuntu-server-builder opened 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1858808

Launchpad details
affected_projects = []
assignee = rjschwei
assignee_name = Robert Schweikert
date_closed = None
date_created = 2020-01-08T15:03:08.154283+00:00
date_fix_committed = None
date_fix_released = None
id = 1858808
importance = undecided
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1858808
milestone = None
owner = rjschwei
owner_name = Robert Schweikert
private = False
status = in_progress
submitter = rjschwei
submitter_name = Robert Schweikert
tags = []
duplicates = []

Launchpad user Robert Schweikert(rjschwei) wrote on 2020-01-08T15:03:08.154283+00:00

It should be possible to have a static IPv4 address and a DHCP IPv6 address and vice versa. This does not work on SUSE distributions as the "BOOTPROTO" setting in the generated ifcfg-* file is not correct.

The BOOTPROTO setting should be

dhcp - if both IPv6 and IPv4 configurations are expected to be supplied by a DHCP server dhcp4 - if IPv4 configuration is expected to be supplied by a DHCP server, IPv6 configuration can be static dhcp6 - IPv6 configuration is expected to be supplied by a DHCP server, IPv4 configuration can be static static - if both IPv6 and IPv4 configurations are defined, or if only one protocol is used and the IP is static

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2020-01-08T15:35:43.054118+00:00

openSuSE docs[1] suggest a bit more detail on BOOTPROTO values:

With BOOTPROTO you can choose in which mode the interface will be set up:

- static: Set up static address(es)

- dhcp: Start a dhcp client (IPV4 and IPv6) on that interface.

- dhcp4: Start a dhcp client (IPv4 only) on that interface.

- dhcp6: Start a dhcp client (IPv6 only) on that interface.

- autoip: Automatic search for a free address and assign it statically.

- dhcp+autoip: Try dhcp4 and use autoip if dhcp fails.

- 6to4: Set up ipv6 over ipv4 tunnel (see man ifcfg-tunnel)

- none: Do not set up the link or ip, a (bonding) master will do it.

If you use dhcp or autoip you may additionally specify static address(es).

# BOOTPROTO=

Note, 'static' is not valid per the docs.

On RedHat etc.

BOOTPROTO=protocol where protocol is one of the following: none — No boot-time protocol should be used. bootp — The BOOTP protocol should be used. dhcp — The DHCP protocol should be used.

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2020-01-08T15:35:58.290347+00:00

From SLES man page:

BOOTPROTO {static*|dhcp|dhcp4|dhcp6|autoip|dhcp+autoip|auto6|6to4|none} Setup protocol. If this variable is empty or missing, it defaults to static. static A fixed addresses specified in IPADDR and related vari- ables and static routing as defined in routes and ifroute- files is configured. This option does not prevent from getting dynamic IPv6 addresses and routes from Router Advertisements, though. dhcp4 dhcp6 dhcp A DHCPv4, DHCPv6 or both clients are started to configure the interface. The setup is considered successful, when at least one dhcp client configures the interface. Addi- tionally to the dhcp client configuration, fixed addresses and routes may also be specified. Note: Static routes take precedence over routes provides by dhcp or other leases, that is, a DHCPv4 route with same metrics as a static one will be skipped. DHCPv6 does not support routing options, an IPv6 Router Advertisement (RA) is applying them.

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2020-01-08T15:42:17.548966+00:00

and the rest from the man page:

         auto4 autoip dhcp+autoip
                 may  be used for a IPv4 zeroconf setup or as fall back to
                 autoip if dhcp4 fails.
          auto6
                 can be used to request to wait for  IPv6  autoconfig  (in
                 kernel),  usable  also in combination with dhcp or static
                 modes, e.g. dhcp+auto6 to request dhcp4, dhcp6  and  also
                 wait  for  auto6.  Default  is to not wait, but apply the
                 RDNSS and DNSSL resolver (lowerered  prio  in  netconfig)
                 settings when they arrive.
          6to4
                 to  set  up  IPv6 tunnel interfaces running in the "6to4"
                 mode.
                 See also ifcfg-tunnel(5) manual page.
          none
                 For bonding slaves, to  skip  the  link-layer  (MTU,  MAC
                 address)  setup  and IP configuration of the interface in
                 ifup. The bonding script handles the link layer  settings
                 itself  at  enslave  time.  See also ifcfg-bonding(5) man
                 page.  Note:  Do not use to just skip the IP setup -- use
                 BOOTPROTO="static"  without  any  addresses in the IPADDR
                 variables (or routes) instead.
ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2020-01-08T15:46:42.836610+00:00

Yes, static is valid. It "works" on RedHat since sysconfig there only expects 'dhcp' or 'bootp' which sets DYNCONFIG=true; so a BOOTPROTO value of 'static' is equivalent.

I suspect having the sysconfig Renderer take a config value of 'flavor' would allow control flow around settings BOOTPROTO and other settings correctly.

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2020-01-10T16:39:55.015466+00:00

https://github.com/canonical/cloud-init/pull/162