Fedora 39
Sponsored Link

DHCP : Configure DHCP Server2023/11/10

 
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 ~]#
dnf -y install dhcp-server
[root@dlp ~]#
vi /etc/dhcp/dhcpd.conf
# create new
# specify domain name
option domain-name     "srv.world";

# specify DNS server hostname or IP address
option domain-name-servers     dlp.srv.world;

# default lease time
default-lease-time 600;

# max lease time
max-lease-time 7200;

# this DHCP server to be declared valid
authoritative;

# specify network address and subnetmask
subnet 10.0.0.0 netmask 255.255.255.0 {
    # specify the range of lease IP address
    range dynamic-bootp 10.0.0.200 10.0.0.254;
    # specify broadcast address
    option broadcast-address 10.0.0.255;
    # specify gateway
    option routers 10.0.0.1;
}

[root@dlp ~]#
systemctl enable --now dhcpd

[2] If Firewalld is running, allow DHCP service. DHCP Server uses [67/UDP].
[root@dlp ~]#
firewall-cmd --add-service=dhcp

success
[root@dlp ~]#
firewall-cmd --runtime-to-permanent

success
[3] It's possible to see leased IP address in the file below from DHCP Server to DHCP Clients.
[root@dlp ~]#
ll /var/lib/dhcpd

total 4
-rw-r--r--. 1 dhcpd dhcpd    0 Jul 19 09:00 dhcpd6.leases
-rw-r--r--. 1 dhcpd dhcpd 1615 Nov 10 11:25 dhcpd.leases
-rw-r--r--. 1 dhcpd dhcpd    0 Jul 19 09:00 dhcpd.leases~

[root@dlp ~]#
cat /var/lib/dhcpd/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,\340OfRT\000U\375\177";

lease 10.0.0.250 {
  starts 5 2023/11/10 02:19:35;
  ends 5 2023/11/10 02:29:35;
  cltt 5 2023/11/10 02:19: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";
}
.....
.....
Matched Content