Perhaps you are looking for a single source of truth deployment strategy by using a single copy of dhcpd.conf to keep all network information like option routers
, option domain-name-servers
, option domain-name
. You may try these steps (Debian):
Define a static IP address for network interface
This is require or else dhcp server won't start.
$ cat /etc/network/interfaces
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.1/24
Optional: Define a fixed ip address in DHCP client configuration
This step is optional unless you want the IP address for your DHCP host.
$ cat /etc/dhcp/dhclient.conf
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
interface "eth0" {
send dhcp-requested-address 192.168.1.1;
}
Define a DHCP pool range for the network
$ cat /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
option domain-name "example.lan";
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.253;
pool {
range 192.168.1.10 192.168.1.200;
}
}
Restart the machine and check you have a static IP address and dhcp server running. Now execute these to get IP address from DHCP server:
# Flush the IP address of interface eth0
$ ip a flush dev eth0
# Remove dhclient lease
$ rm /var/lib/dhcp/dhclient.*
# Start dhclient for interface eth0
dhclient -v eth0
A new IP address shall get allocate for the interface eth0
with DHCP requested options.