DHCP : Configure DHCP Server2023/06/15 |
|
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 7 : specify domain name option domain-name "srv.world" ;
# line 8 : specify nameserver's hostname or IP address option domain-name-servers dlp.srv.world ;
# line 21 : uncomment (this DHCP server to be declared valid) authoritative; # add to the end # 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;
}
systemctl restart isc-dhcp-server |
| [2] | It's possible to see leased IP address in the file below from DHCP Server to DHCP Clients. |
|
root@dlp:~# ll /var/lib/dhcp drwxrwxr-x 2 root dhcpd 4096 Apr 26 07:42 ./ drwxr-xr-x 40 root root 4096 Apr 26 07:16 ../ -rw-r--r-- 1 dhcpd dhcpd 580 Apr 26 07:48 dhcpd.leases -rw-rw-r-- 1 root dhcpd 219 Apr 26 07:36 dhcpd.leases~ -rw-r--r-- 1 dhcpd dhcpd 219 Apr 26 07:36 dhcpd6.leases -rw-rw-r-- 1 root dhcpd 0 Apr 26 07:36 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.1
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
server-duid "\000\001\000\001)\372^\331RT\000\253\225,";
lease 10.0.0.200 {
starts 2 2022/04/26 07:48:59;
ends 2 2022/04/26 07:58:59;
cltt 2 2022/04/26 07:48:59;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 52:54:00:87:24:2c;
uid "\377VPM\230\000\002\000\000\253\021\022\004\021\002*n\225\336";
}
.....
.....
|