Bug 2177733 - nmstate support for both dhcp and static IP at the same NIC
Summary: nmstate support for both dhcp and static IP at the same NIC
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: nmstate
Version: 9.4
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Gris Ge
QA Contact: Mingyu Shi
Mayur Patil
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-13 14:28 UTC by Nir Magnezi
Modified: 2023-07-13 07:25 UTC (History)
9 users (show)

Fixed In Version: nmstate-2.2.10-3.el9
Doc Type: Enhancement
Doc Text:
Feature: Support assigning static IP address on DHCP enabled interface Reason: Customer of openshift assisted installer would like nmstate to support assigning static IP address on DHCP/auticonf enabled interface. Result: Introduced two properties for IP address: * `valid-left`: seconds for IP address been valid. `forever` means static. * `preferred_left`: seconds for IP address been preferred. `forever` means static. With above properties, we can identify which certain IP address is retrieved from DHCP/Autoconf so we don't convert dynamic IP address to static when user apply the queried state back. With this patch, user is allowed to set static IP address with `dhcp: true` and/or `autoconf: true`. When desire state has DHCP/Autoconf disabled but all desired IP addresses are dynamic, nmstate will convert those dynamic IP to static. This is common use case where user just copy retrieved dynamic IP and hoping nmstate can convert it to static.
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github nmstate nmstate pull 2303 0 None Merged ip: Support static IP address on with auto ip stack 2023-04-10 11:38:09 UTC
Red Hat Issue Tracker NMT-383 0 None None None 2023-03-14 08:30:31 UTC
Red Hat Issue Tracker RHELPLAN-151689 0 None None None 2023-03-14 08:33:20 UTC

Description Nir Magnezi 2023-03-13 14:28:18 UTC
Description of problem:
=======================
We have a customer that is using nmstate with assisted installer.
They use a network configuration that is not currently supported by nmstate, and I wish to know if it could change.
They need to set an IP address to a DHCP-enabled NIC; however, this is currently blocked by nmstate.
Version-Release number of selected component (if applicable):

Some details about their use case:
==================================
The SNO (single node Openshift) server will have a static internal IP set to 192.168.x.y at the factory - an initial server install. This IP will never change and will allow the cluster to move and alter external addresses without affecting the operation of the cluster.

Actual results:
===============
Error: https://github.com/nmstate/nmstate/blob/ad669296545a0fb7f3bd9745155016c8fd474aaf/rust/src/lib/ip.rs#L277-L286

Expected results:
=================
A nic with both DHCP and a static IP

Comment 8 Gris Ge 2023-04-04 11:08:44 UTC
Patch sent to upstream: https://github.com/nmstate/nmstate/pull/2303


Introducing two properties for IP address:
 * `valid-left`: seconds for IP address been valid. `forever` means
   static.
 * `preferred_left`: seconds for IP address been preferred. `forever`
   means static.

With above properties, we can identify which certain IP address is
retrieved from DHCP/Autoconf so we don't convert dynamic IP address to
static when user apply the queried state back.

With this patch, user is allowed to set static IP address with
`dhcp: true` and/or `autoconf: true`.

When desire state has DHCP/Autoconf disabled but all desired IP
addresses are dynamic, nmstate will convert those dynamic IP to static.
This is common use case where user just copy retrieved dynamic IP and
hoping nmstate can convert it to static.


Example query output of a interface has both static IP and dynamic IP:

```yml
---
interfaces:
  - name: dhcpcli
    type: ethernet
    state: up
    ipv4:
      enabled: true
      dhcp: true
      address:
      - ip: 192.0.2.99
        prefix-length: 24
      - ip: 192.0.2.97
        prefix-length: 24
        valid-left: 30sec
        preferred-left: 30sec
    ipv6:
      enabled: true
      dhcp: true
      autoconf: true
      address:
      - ip: 2001:db8:a::9
        prefix-length: 64
      - ip: 2001:db8:a::2
        prefix-length: 64
        valid-left: 30sec
        preferred-left: 30sec
```

Comment 9 Gris Ge 2023-04-04 11:20:55 UTC
Please be aware above two new properties is query only. IP address with above properties set to non-forever will be ignored unless it meet the special use case above.

Comment 14 Mingyu Shi 2023-05-22 10:03:55 UTC
Verified with:
nmstate-2.2.10-3.el9.x86_64
nispor-1.2.10-1.el9.x86_64
NetworkManager-1.43.8-1.el9.x86_64
DISTRO=RHEL-9.3.0-updates-20230520.44


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