DHCP : Configure DHCP Server2024/04/29 |
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; } 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 total 20 drwxrwxr-x 2 root dhcpd 4096 Apr 29 13:43 ./ drwxr-xr-x 47 root root 4096 Apr 29 13:41 ../ -rw-r--r-- 1 dhcpd dhcpd 608 Apr 29 13:44 dhcpd.leases -rw-rw-r-- 1 root dhcpd 222 Apr 29 13:41 dhcpd.leases~ -rw-r--r-- 1 dhcpd dhcpd 222 Apr 29 13:41 dhcpd6.leases -rw-rw-r-- 1 root dhcpd 0 Apr 29 13:41 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 1 2024/04/29 13:44:15; ends 1 2024/04/29 13:54:15; cltt 1 2024/04/29 13:44:15; binding state active; next binding state free; rewind binding state free; hardware ethernet 52:54:00:4c:63:11; uid "\377VPM\230\000\002\000\000\253\021\310wMr\266\016\033\204"; client-hostname "ubuntu"; } ..... ..... |