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

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

To configure a Linux DHCP client (dhclient) to persistently look for an IP address lease, you can use the -p option when starting the client.

For example, to start the dhclient service and persistently look for an IP address lease on the eth0 interface, you can use the following command:

ref‮ot re‬:lautturi.com
sudo dhclient -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhclient/dhclient.eth0.leases eth0

This will start the dhclient service and persistently look for an IP address lease on the eth0 interface. The -pf and -lf options specify the PID file and lease file, respectively.

To make the configuration persistent across reboots, you can add the dhclient command to the system startup script or use a tool such as systemd to manage the service.

For example, to use systemd to manage the dhclient service, you can create a unit file called dhclient@.service in the /etc/systemd/system directory with the following content:

[Unit]
Description=DHCPv4 Client
After=network.target

[Service]
Type=forking
ExecStart=/sbin/dhclient -pf /run/dhclient.%I.pid -lf /var/lib/dhclient/dhclient
Created Time:2017-10-28 14:02:23  Author:lautturi