This article will describe installing dhcp-server and running DHCP server which provides IP address and DNS information.
Table of Contents
1 dhcp-server
Install dhcp-server.
> sudo zypper -n in dhcp-server > sudo systemctl enable dhcpd
2 /etc/dhcpd.conf
Define domain name, DHCP server and gateway. Mapping MAC address 52:54:00:cb:63:65 to IP address 192.168.11.128.
> sudo su -c ' cat <<EOF > /etc/dhcpd.conf subnet 192.168.11.0 netmask 255.255.255.0 { option domain-name "my.net"; option domain-name-servers 192.168.11.84, 192.168.11.1; option routers 192.168.11.1; } host debian-8 { hardware ethernet 52:54:00:cb:63:65; fixed-address 192.168.11.128; } EOF '
3 /etc/sysconfig/dhcpd
You must set DHCPD_INTERFACE in /etc/sysconfig/dhcpd. Set interface name which is displayed by /sbin/ifconfig. This article uses "ens3".
> sudo sed -e 's/^DHCPD_INTERFACE=.*/DHCPD_INTERFACE="ens3"/g' \ -i /etc/sysconfig/dhcpd
Start dhcpd.
> sudo systemctl start dhcpd
4 Execution result
Checking IP address on MAC address 52:54:00:cb:63:65 machine. IP address is provided.
> ifconfig ens3 Link encap:Ethernet HWaddr 52:54:00:CB:63:65 inet addr:192.168.11.128 Bcast:192.168.11.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fecb:6365/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:7127 errors:0 dropped:0 overruns:0 frame:0 TX packets:1140 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:595915 (581.9 Kb) TX bytes:106931 (104.4 Kb)
DNS information is provided.
> cat /etc/resolv.conf <snip> search my.net
nameserver 192.168.11.84 nameserver 192.168.11.1