Fedora 29: Install dhcp for DHCP server

This article will describe installing dhcp and running DHCP server.

1 Install dhcp

Install dhcp package with dnf.

$ sudo dnf install -y dhcp
$ sudo firewall-cmd --add-service=dhcp --permanent
$ sudo firewall-cmd --reload
$ sudo systemctl enable dhcpd
$ sudo systemctl restart dhcpd

2 /etc/dhcp/dhcpd.conf

Define domain name, DHCP server IP address and gateway IP address. MAC address 52:54:00:5e:7a:a4 machie is assigned IP address 192.168.11.250 and hostname "client.hiroom2.com".

$ cat /etc/dhcp/dhcpd.conf
subnet 192.168.11.0 netmask 255.255.255.0 {
  option domain-name "hiroom2.com";
  option domain-name-servers 192.168.11.2, 192.168.11.1;
  option routers 192.168.11.1;
}

host client {
  hardware ethernet 52:54:00:5e:7a:a4;
  fixed-address 192.168.11.250;
  option host-name "client.hiroom2.com";
}

Restart dhcpd for update confituration.

$ sudo systemctl restart dhcpd

3 Execution result

Run the following command on client machine.

hostname is provided.

$ hostname -f
client.hiroom2.com

IP address is provided.

$ ip a s
<snip>
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel
  state UP group default qlen 1000
    link/ether 52:54:00:5e:7a:a4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.250/24 brd 192.168.11.255 scope global dynamic ens3
       valid_lft 43069sec preferred_lft 43069sec
    inet6 fe80::6501:7500:7614:8a9f/64 scope link
       valid_lft forever preferred_lft forever

DNS servers are provided.

$ cat /etc/resolv.conf
# Generated by NetworkManager
search hiroom2.com
nameserver 192.168.11.2
nameserver 192.168.11.1