DHCP : Configure DHCP Server2026/04/24 |
|
Configure DHCP ( Dynamic Host Configuration Protocol ) Server to assign IP addresses to client hosts in local network. |
|
| [1] | Install and Configure DHCP. On this example, it shows only for IPv4 configuration. |
|
root@dlp:~#
apt -y install isc-dhcp-server
root@dlp:~#
vi /etc/default/isc-dhcp-server # line 4 : uncomment DHCPDv4_CONF=/etc/dhcp/dhcpd.conf # line 17 : specify interface to listen (replace it to your environment) INTERFACESv4=" enp1s0 "
root@dlp:~#
vi /etc/dhcp/dhcpd.conf # line 10 : specify domain name option domain-name "srv.world"; # line 11 : specify nameserver's hostname or IP address option domain-name-servers dlp.srv.world; # line 24 : uncomment (this DHCP server to be declared valid) authoritative; # add to last line # specify network address and subnetmask subnet 10.0.0.0 netmask 255.255.255.0 { # specify gateway option routers 10.0.0.1; # specify subnet mask option subnet-mask 255.255.255.0; # specify the range of lease IP address range dynamic-bootp 10.0.0.200 10.0.0.254; }root@dlp:~# systemctl restart isc-dhcp-server
|
| [2] | If UFW is enabled, allow DHCP service. DHCP server uses [67/UDP]. |
|
root@dlp:~# ufw allow bootps Rule added Rule added (v6) |
| [3] | It's possible to see leased IP address in the file below from DHCP Server to DHCP Clients. |
|
root@dlp:~# ll /var/lib/dhcp total 20 drwxrwxr-x 2 root dhcpd 4096 Apr 24 10:04 ./ drwxr-xr-x 49 root root 4096 Apr 24 09:57 ../ -rw-r--r-- 1 dhcpd dhcpd 617 Apr 24 10:05 dhcpd.leases -rw-rw-r-- 1 root dhcpd 222 Apr 24 09:57 dhcpd.leases~ -rw-r--r-- 1 dhcpd dhcpd 222 Apr 24 09:57 dhcpd6.leases -rw-rw-r-- 1 root dhcpd 0 Apr 24 09:57 dhcpd6.leases~root@dlp:~# cat /var/lib/dhcp/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.4.3-P1
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
server-duid "\000\001\000\001-\302`xRT\000\227\252\314";
lease 10.0.0.200 {
starts 5 2026/04/24 10:05:35;
ends 5 2026/04/24 10:15:35;
cltt 5 2026/04/24 10:05:35;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:e5:f5:43;
uid "\001\000\014)\345\365C";
set vendor-class-identifier = "MSFT 5.0";
client-hostname "RX-0";
}
.....
.....
|
| Sponsored Link |
|
|