OpenSUSE Leap 15: Install dhcp-server for DHCP server

This article will describe installing dhcp-server and running DHCP server.

1 Install dhcp-server

Install dhcp-server with zypper.

> sudo zypper -n in dhcp-server
> sudo systemctl enable dhcpd

You must set DHCPD_INTERFACE in /etc/sysconfig/dhcpd. Set interface name which is displayed by /sbin/ifconfig. This article uses "eth0".

> sudo sed -e 's/^DHCPD_INTERFACE=.*/DHCPD_INTERFACE="eth0"/g' \
           -i /etc/sysconfig/dhcpd

2 /etc/dhcpd.conf

Define domain name, DHCP server and gateway. Mapping MAC address 52:54:00:5e:7a:a4 to IP address

> DHCP_CLIENT_MACADDR=52:54:00:5e:7a:a4
> cat <<EOF | sudo tee /etc/dhcpd.conf
subnet netmask {
  option domain-name "";
  option domain-name-servers ${DHCP_SERVER_IPADDR};
  option routers;
host client {
  hardware ethernet ${DHCP_CLIENT_MACADDR};
  option host-name "client";

Restart dhcpd.

> sudo systemctl restart dhcpd

3 Execution result

Checking IP address on client machine.

IP address is provided.

> ip a s
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP group default qlen 1000
    link/ether 52:54:00:5e:7a:a4 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe5e:7aa4/64 scope link
       valid_lft forever preferred_lft forever

DNS information is provided.

> cat /etc/resolv.conf

Hostname is provided.

> hostname -f