First you need to install dhcp package (may vary depending on your distribution). Next you need to edit main configuration file /etc/dhcpd.conf where you can set all necessary information.
Here is my example configuration:
default-lease-time 1800; max-lease-time 7200; log-facility local7; subnet 172.16.0.0 netmask 255.255.255.0 { range 172.16.0.101 172.16.0.254; option domain-name-servers 192.168.0.1, 88.212.8.8, 88.212.8.88; #filename "pxelinux.0"; # the PXELinux boot agent option subnet-mask 255.255.255.0; option broadcast-address 172.16.0.255; option routers 172.16.0.1; } host LenovoZ560 { hardware ethernet aa:aa:aa:aa:aa:aa; fixed-address 172.16.0.2; # option domain-name-servers 8.8.8.8; option subnet-mask 255.255.255.0; option broadcast-address 172.16.0.255; option routers 172.16.0.1; }
Short description:
- subnet section defines IP range from which addresses will be assigned
- there are also DNS servers, which you need to adjust to your DNS addresses
- the host section is optional, in general it serves to specify hosts (identified by hardware ethernet address) which will obtain always the same IP address (fixed-address).
Next step is to enable dhcpd startup during boot:
systemctl enable dhcpd4
NOTE: this defaults to eth0 interface, if you want your dhcpd service to assign addresses on other interface, copy /usr/lib/systemd/system/dhcpd4.service to /etc/systemd/system/multi-user.target.wants/ edit this file and change eth0 to your desired network interface.
NOTE: do not edit files in /usr/lib/systemd/system/ because they might be overwritten during systemd update.
No comments:
Post a Comment