Este contenido no está disponible en el idioma seleccionado.

1.3. Configuring the DHCP Client Behavior


A Dynamic Host Configuration Protocol (DHCP) client requests the dynamic IP address and corresponding configuration information from a DHCP server each time a client connects to the network.
Note that NetworkManager calls the DHCP client, dhclient by default.

Requesting an IP Address

When a DHCP connection is started, a dhcp client requests an IP address from a DHCP server. The time that a dhcp client waits for this request to be completed is 60 seconds by default. You can configure the ipv4.dhcp-timeout property using the nmcli tool or the IPV4_DHCP_TIMEOUT option in the /etc/sysconfig/network-scripts/ifcfg-ifname file. For example, using nmcli:
~]# nmcli connection modify enp1s0 ipv4.dhcp-timeout 10nmcli connection modify enp1s0 ipv4.dhcp-timeout 10nmcli connection modify enp1s0 ipv4.dhcp-timeout 10
Copy to Clipboard Toggle word wrap
If an address cannot be obtained during this interval, the IPv4 configuration fails. The whole connection may fail, too, and this depends on the ipv4.may-fail property:
  • If ipv4.may-fail is set to yes (default), the state of the connection depends on IPv6 configuration:
    1. If the IPv6 configuration is enabled and successful, the connection is activated, but the IPv4 configuration can never be retried again.
    2. If the IPv6 configuration is disabled or does not get configured, the connection fails.
  • If ipv4.may-fail is set to no the connection is deactivated. In this case:
    1. If the autoconnect property of the connection is enabled, NetworkManager retries to activate the connection as many times as set in the autoconnect-retries property. The default is 4.
    2. If the connection still cannot acquire the dhcp address, auto-activation fails.
      Note that after 5 minutes, the auto-connection process starts again and the dhcp client retries to acquire an address from the dhcp server.

Requesting a Lease Renewal

When a dhcp address is acquired and the IP address lease cannot be renewed, the dhcp client is restarted for three times every 2 minutes to try to get a lease from the dhcp server. Each time, it is configured by setting the ipv4.dhcp-timeout property in seconds (default is 60) to get the lease. If you get a reply during your attempts, the process stops and you get your lease renewed.
After three attempts failed:
  • If ipv4.may-fail is set to yes (default) and IPv6 is successfully configured, the connection is activated and the dhcp client is restarted again every 2 minutes.
  • If ipv4.may-fail is set to no, the connection is deactivated. In this case, if the connection has the autoconnect property enabled, the connection is activated from scratch.

1.3.1. Making DHCPv4 Persistent

To make DHCPv4 persistent both at startup and during the lease renewal processes, set the ipv4.dhcp-timeout property either to the maximum for a 32-bit integer (MAXINT32), which is 2147483647, or to the infinity value:
~]$ nmcli connection modify enps1s0 ipv4.dhcp-timeout infinitynmcli connection modify enps1s0 ipv4.dhcp-timeout infinitynmcli connection modify enps1s0 ipv4.dhcp-timeout infinity
Copy to Clipboard Toggle word wrap
As a result, NetworkManager never stops trying to get or renew a lease from a DHCP server until it is successful.
To ensure a DHCP persistent behavior only during the lease renewal process, you can manually add a static IP to the IPADDR property in the /etc/sysconfig/network-scripts/ifcfg-enp1s0 configuration file or by using nmcli:
~]$ nmcli connection modify enp1s0 ipv4.address 192.168.122.88/24nmcli connection modify enp1s0 ipv4.address 192.168.122.88/24nmcli connection modify enp1s0 ipv4.address 192.168.122.88/24nmcli connection modify enp1s0 ipv4.address 192.168.122.88/24
Copy to Clipboard Toggle word wrap
When an IP address lease expires, the static IP preserves the IP state as configured or partially configured (you can have an IP address, but you are not connected to the Internet), making sure that the dhcp client is restarted every 2 minutes.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat