Este conteúdo não está disponível no idioma selecionado.
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
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
If an address cannot be obtained during this interval, the IPv4 configuration fails. The whole connection may fail, too, and this depends on the
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 10
~]# nmcli connection modify enp1s0 ipv4.dhcp-timeout 10
ipv4.may-fail property:
- If
ipv4.may-failis set toyes(default), the state of the connection depends on IPv6 configuration:- If the IPv6 configuration is enabled and successful, the connection is activated, but the IPv4 configuration can never be retried again.
- If the IPv6 configuration is disabled or does not get configured, the connection fails.
- If
ipv4.may-failis set tonothe connection is deactivated. In this case:- If the
autoconnectproperty of the connection is enabled, NetworkManager retries to activate the connection as many times as set in theautoconnect-retriesproperty. The default is 4. - 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-failis set toyes(default) and IPv6 is successfully configured, the connection is activated and the dhcp client is restarted again every 2 minutes. - If
ipv4.may-failis set tono, the connection is deactivated. In this case, if the connection has theautoconnectproperty enabled, the connection is activated from scratch.
1.3.1. Making DHCPv4 Persistent Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
To make DHCPv4 persistent both at startup and during the lease renewal processes, set the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
As a result, NetworkManager never stops trying to get or renew a lease from a DHCP server until it is successful.
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 infinity
~]$ nmcli connection modify enps1s0 ipv4.dhcp-timeout infinity
To ensure a DHCP persistent behavior only during the lease renewal process, you can manually add a static IP to the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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/24
~]$ nmcli connection modify enp1s0 ipv4.address 192.168.122.88/24
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.