RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1577947 - static network configuration putting prefix into IPADDR instead of PREFIX
Summary: static network configuration putting prefix into IPADDR instead of PREFIX
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Ryan McCabe
QA Contact: xiachen
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-14 13:42 UTC by Martin Steigerwald
Modified: 2024-11-20 07:53 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-06-19 04:17:35 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Launchpad 1771116 0 None None None 2018-05-14 13:42:26 UTC

Description Martin Steigerwald 2018-05-14 13:42:26 UTC
Using CentOS but reporting here as the fix needs to go into the upstream source and then RHEL RPM anyway before going into CentOS, also reported there, see under "Additional info".

Description of problem:

cloud-init configures static network wrongly as:

IPADDR=10.0.88.151/8

instead of

IPADDR=10.0.88.151
PREFIX=8


Version-Release number of selected component (if applicable):

cloud-init-0.7.9-24.el7.centos.x86_64

How reproducible:

Always.


Steps to Reproduce:
1. Have a network configuration like (here via NoCloud source on Proxmox):

[root@centos1 ~]# mount | grep sr0
/dev/sr0 on /mnt/zeit type iso9660 (ro,relatime)
[root@centos1 ~]# cat /mnt/zeit/
meta-data       network-config  user-data       
[root@centos1 ~]# cat /mnt/zeit/network-config 
version: 1
config:
    - type: physical
      name: eth0
      mac_address: F2:15:C8:E1:0A:49
      subnets:
      - type: static
        address: 10.0.88.151/8
        gateway: 10.0.0.4
    - type: nameserver
      address:
      - 10.0.0.4
      search:
      - somedomain.de
 
2. Boot the image with this cloud init configuration


Actual results:

[root@centos1 network-scripts]# cat ifcfg-eth0.cloud-init.orig
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
GATEWAY=10.0.0.4
HWADDR=F2:15:C8:E1:0A:49
IPADDR=10.0.88.151/8
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

Which leads to:

[root@centos1 ~]# LANG=C ifup eth0
ipcalc: both netmask and prefix specified
Usage: ipcalc [OPTION...]
  -c, --check Validate IP address for specified address family
  -4, --ipv4 IPv4 address family (default)
  -6, --ipv6 IPv6 address family
  -b, --broadcast Display calculated broadcast address
  -h, --hostname Show hostname determined via DNS
  -m, --netmask Display default netmask for IP (class A, B, or C)
  -n, --network Display network address
  -p, --prefix Display network prefix
  -s, --silent Don't ever display error messages

Help options:
  -?, --help Show this help message
  --usage Display brief usage message
ipcalc: both netmask and prefix specified
Usage: ipcalc [OPTION...]
  -c, --check Validate IP address for specified address family
  -4, --ipv4 IPv4 address family (default)
  -6, --ipv6 IPv6 address family
  -b, --broadcast Display calculated broadcast address
  -h, --hostname Show hostname determined via DNS
  -m, --netmask Display default netmask for IP (class A, B, or C)
  -n, --network Display network address
  -p, --prefix Display network prefix
  -s, --silent Don't ever display error messages

Help options:
  -?, --help Show this help message
  --usage Display brief usage message
ipcalc: both netmask and prefix specified
Usage: ipcalc [OPTION...]
  -c, --check Validate IP address for specified address family
  -4, --ipv4 IPv4 address family (default)
  -6, --ipv6 IPv6 address family
  -b, --broadcast Display calculated broadcast address
  -h, --hostname Show hostname determined via DNS
  -m, --netmask Display default netmask for IP (class A, B, or C)
  -n, --network Display network address
  -p, --prefix Display network prefix
  -s, --silent Don't ever display error messages

Help options:
  -?, --help Show this help message
  --usage Display brief usage message
arping: 10.0.88.151/8: Name or service not known
Error: any valid prefix is expected rather than "10.0.88.151/8/".
ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Error adding address 10.0.88.151/8 for eth0.
arping: 10.0.88.151/8: Name or service not known
Error: any valid prefix is expected rather than "10.0.88.151/8/".
RTNETLINK answers: File exists


Expected results:

[root@centos1 network-scripts]# cat ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
GATEWAY=10.0.0.4
HWADDR=F2:15:C8:E1:0A:49
IPADDR=10.0.88.151
PREFIX=8
ONBOOT=yes
TYPE=Ethernet
USERCTL=no


Additional info:

Upstream bug report:

network configuration fails on CentOS 7.5: using dhcp instead of static address
https://bugs.launchpad.net/cloud-init/+bug/1771116


I believe the offending code to be in "_write_network" in /usr/lib/python2.7/site-packages/cloudinit/distros/rhel.p

Comment 2 xiachen 2020-06-19 04:17:35 UTC
This bug could be reproduced on the old version, cloud-init-0.7.9-24.el7.x86_64, the same behavior as bug description.
but this issue is gone on latest version of cloud-init.
so close it as CURRENTRELEASE. 
If anyone find this issue with latest cloud-init please re-open and provide the failing cloud-init version.

-----------------------------------------------------
I tested three latest cloud-init for different RHEL, did not find the issue.
cloud-init-18.2-1.el7_6.3.x86_64 (rhel 7.6.0.z)
cloud-init-18.5-12.el8_2.1.noarch (rhel 8.2.0.z)
cloud-init-19.4-4.el8.noarch (rhel 8.3.0)

Test Details,
Step1. prepare an network-config file,
version: 1
config:
  - type: physical
    name: eth0
    subnets:
       - type: static
         address: 192.168.23.14/27
         gateway: 192.168.23.1
Step2.launch an VM via NoCloud datasource
$ qemu-img create -f qcow2 -o backing_file=rhel-guest-image-8.3-194.x86_64.qcow2 example.qcow2
$ genisoimage -o example_config.iso -V cidata -r -J user-data meta-data network-config
$ virt-install -n example -r 512 --import --disk path=./example.qcow2 --disk path=./example_config.iso,device=cdrom --nographics

Step3.login VM and check network configuration, the value of IPADDR and NETMASK is correct.
[root@myhost network-scripts]# cat ifcfg-eth0 
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
GATEWAY=192.168.23.1
IPADDR=192.168.23.14
NETMASK=255.255.255.224
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no

-----------------------------------------------------

BTW, the upstream bug was closed with an confirmation 'no issue with current CentOS 7.6 images' on 2019-08-05.
https://bugs.launchpad.net/cloud-init/+bug/1771116

Comment 3 jeannette9728miller 2024-05-14 04:56:27 UTC
It seems you’re encountering an issue with cloud-init where the static network configuration is incorrectly placing the prefix within the IPADDR field instead of using a separate PREFIX field. This bug was reported as Bug 1577947 and appears to have been addressed in the current release1.
https://www.maxim-timeclock.com
To resolve this issue, you should ensure that you’re using the latest version of cloud-init where this bug has been fixed. If you’re still experiencing this problem with the latest version, you may need to manually edit the network configuration file to separate the IP address and the prefix into the IPADDR and PREFIX fields, respectively.

Comment 4 Martin Steigerwald 2024-05-15 09:05:04 UTC
@admins: I believe comment #3 is spam. If you agree please delete. Feel free to also delete this comment. Thanks, Martin


Note You need to log in before you can comment on or make changes to this bug.