DHCP

DHCP, or Dynamic Host Configuration Protocol, is a network management protocol that automates the process of assigning IP addresses and other network configuration parameters to devices on a network. This crucial technology plays a vital role in modern network infrastructure, from small home networks to large enterprise environments.

In essence, DHCP eliminates the need for manual IP address configuration, making it easier for devices to join and communicate on a network. It dynamically assigns IP addresses, subnet masks, default gateways, and other network settings to client devices, streamlining network administration and reducing the potential for configuration errors.

dhclient

On Ubuntu systems, dhclient works in conjunction with NetworkManager for easier network configuration management.

Configuration file located at /etc/dhcp/dhclient.conf

To view IP lease info, run “dhclient -v” command

root@sok-mysql-fix:~# dhclient -v
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/00:16:3e:bf:97:d0
Sending on   LPF/eth0/00:16:3e:bf:97:d0
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0xc266324)
DHCPOFFER of 10.18.211.81 from 10.18.211.1
DHCPREQUEST for 10.18.211.81 on eth0 to 255.255.255.255 port 67 (xid=0x2463260c)
DHCPACK of 10.18.211.81 from 10.18.211.1 (xid=0xc266324)
RTNETLINK answers: File exists
bound to 10.18.211.81 -- renewal in 1759 seconds.
root@sok-mysql-fix:~# 

Or check the content of file /var/lib/dhcp/dhclient.leases

root@sok-mysql-fix:~# cat /var/lib/dhcp/dhclient.leases
lease {
  interface "eth0";
  fixed-address 10.18.211.81;
  option subnet-mask 255.255.255.0;
  option routers 10.18.211.1;
  option dhcp-lease-time 3600;
  option dhcp-message-type 5;
  option domain-name-servers 10.18.211.1;
  option dhcp-server-identifier 10.18.211.1;
  option dhcp-renewal-time 1800;
  option broadcast-address 10.18.211.255;
  option dhcp-rebinding-time 3150;
  option host-name "sok-mysql-fix";
  option domain-name "lxd";
  renew 0 2024/07/07 17:47:55;
  rebind 0 2024/07/07 18:11:06;
  expire 0 2024/07/07 18:18:36;
}
root@sok-mysql-fix:~# 

To manually request a lease

 dhclient <interface>

To release an IP address

 dhclient -r <interface>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *