Dhcp

From wiki
Revision as of 15:13, 11 May 2019 by Hdridder (talk | contribs) (Created page with "Dynamic Host Configuration Protocol Sample configuration file (/etc/dhcp/dhcpd.conf). <syntaxhighlight lang=bash> # ddns-update-style none; # option definitions common to a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Dynamic Host Configuration Protocol

Sample configuration file (/etc/dhcp/dhcpd.conf).

#
ddns-update-style none;

# option definitions common to all supported networks.
option domain-name "domain.tld";
option domain-name-servers 192.168.1.2, 208.67.222.222;
option routers 192.168.1.254;
option broadcast-address 192.168.1.255;
option ntp-servers 192.168.1.4;

# 1 day (fine for home networks, e.g. hotspots should have far shorter lease times) 
default-lease-time 86400;
# 1 week
max-lease-time 604800;

authoritative;

log-facility local7;

# Known hosts get fixed IP address defined in DNS-server
group {
 deny unknown-clients;
 # One week, these are sort of fixed addresses.
 default-lease-time 604800;

 host host1name {
  hardware ethernet ff:ff:ff:ff:ff:ff;
  fixed-address host1name.domain.tld;
 }
 host host2name {
  hardware ethernet ff:ff:ff:ff:ff:ff;
  fixed-address host2name.domain.tld;
 }
}
# All other get an address from the range
subnet 192.168.1.0 netmask 255.255.255.0 {
 range 192.168.1.100 192.168.1.199;
}

The leases are kept track of in /var/lib/dhcp/dhcpd.leases An ordinary entry looks like: tstp and cltt are for the failover protocol, most other entries are self-explaining I think.

lease 192.168.1.133 {
  starts 6 2021/03/18 11:22:00;
  ends 0 2021/03/19 11:22:00;
  tstp 0 2021/03/19 11:22:00;
  cltt 6 2021/03/19 11:22:00;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet ff:ff:ff:ff:ff:ff;
  client-hostname "host3name";
}