Configure Linux DHCP client ( dhclient ) to persistently look for an IP address lease

Q. I’ve HP Laptop installed with CentOS 5 workstation operating system. How can I configure Linux dhclient command to continuously requests an IP lease until one is granted by DHCP Server / Router?

ADVERTISEMENTS

A. You need to set the PERSISTENT_DHCLIENT option by editing Ethernet configuration file. This option is turned off by default.

Login as the root user

Open /etc/sysconfig/network-scripts/ifcfg-eth0 file to set eth0 to persistently look for an IP address lease:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append line PERSISTENT_DHCLIENT=1, at the end configuration should look as follows:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
PERSISTENT_DHCLIENT=1

Save and close the file. Restart networking service or reboot laptop / desktop to test the changes:
# /etc/init.d/networking restart

Please note that your network switches and other protocol may need to configure properly to work with this option.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • skynet May 13, 2009 @ 21:32

    “Save and close the file. Restart networking service or reboot laptop / desktop to test the changes:
    # /etc/init.d/networking restart”

    should be:
    # /etc/init.d/network restart

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.