Cookbooks
dhcp
documentation
Dhcp Subnet

dhcp_subnet

Back to resource list

Create and manage the main DHCPD configuration. (https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcpdconf (opens in a new tab))

Introduced: v7.0.0

Actions

  • :create
  • :delete

Properties

NameTypeDefaultDescriptionAllowed Values
commentStringnilComment to add to the configuration file
ip_versionSymbol:ipv4Select DHCP or DHCPv6 server to configure:ipv4, :ipv6
conf_dirString/etc/dhcp/dhcpd(6).d/classes.dDirectory to create configuration file in
cookbookString/etc/dhcp/dhcpd(6).d/classes.dCookbook to source configuration file template from
templateString/etc/dhcp/dhcpd(6).d/classes.dTemplate to use to generate the configuration file
ownerStringPlatform dependantOwner of the generated configuration file
groupStringPlatform dependantGroup of the generated configuration file
modeString'0640'Filemode of the generated configuration file
shared_networkTrue, FalsefalseDHCP failover configuration file path
subnetStringnilSubnet address
netmaskStringnilSubnet network for IPv4 subnets
prefixStringnilSubnet prefix for IPv6 subnets
subnetStringnilSubnet address
subnetStringnilSubnet address
parametersArray, HashnilDHCPD parameters for the subnet
optionsArray, HashnilDHCPD options for the subnet
evalsArraynilDHCPD conditional statements for the subnet (see dhcp-eval(5))
keysHashnilTSIG keys configuration
zonesHashnilDynamic DNS zone configuration
allowArraynil
denyArraynil
extra_linesString, ArraynilExtra lines to append to the configuration file
poolsHash, ArraynilPool configuration hash(es), accepts most properties (see dhcpd.conf(5))

Examples

dhcp_subnet '192.168.9.0' do
  comment 'Listen Subnet Declaration'
  subnet '192.168.9.0'
  netmask '255.255.255.0'
end
 
dhcp_subnet 'basic' do
  comment 'Basic Subnet Declaration'
  subnet '192.168.0.0'
  netmask '255.255.255.0'
  options [
    'routers 192.168.0.1'
    'time-offset 10',
  ]
  pool 'range' => '192.168.0.100 192.168.0.200'
end
dhcp_subnet 'dhcpv6_listen' do
  ip_version :ipv6
  comment 'Testing DHCPv6 Basic Subnet'
  subnet '2001:db8:1::'
  prefix 64
end
 
dhcp_subnet 'dhcpv6_basic' do
  ip_version :ipv6
  comment 'Testing DHCPv6 Basic Subnet'
  subnet '2001:db8:2:1::'
  prefix 64
  options(
    'domain-name' => '"test.domain.local"',
    'dhcp6.name-servers' => '2001:4860:4860::8888, 2001:4860:4860::8844'
  )
  parameters(
    'ddns-domainname' => '"test.domain.local"',
    'default-lease-time' => 28800
  )
  range [
    '2001:db8:2:1::1:0/112',
  ]
end