Cookbooks
dhcp
documentation
Dhcp Shared Network

dhcp_shared_network

Back to resource list

Create a DHCPD shared network configuration. (https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcpdconf#reference-declarations (opens in a new tab) - The shared-network statement)

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/hosts.dDirectory to create configuration file in
cookbookString/etc/dhcp/dhcpd(6).d/hosts.dCookbook to source configuration file template from
templateString/etc/dhcp/dhcpd(6).d/hosts.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
subnetsHashnilSubnets for the DHCPD shared network

Examples

dhcp_shared_network 'single' do
  subnets(
    '192.168.1.0' => {
      'subnet' => '192.168.1.0',
      'netmask' => '255.255.255.0',
      'options' => {
        'broadcast-address' => '192.168.1.255',
        'routers' => '192.168.1.1',
      },
      'pool' => {
        'range' => '192.168.1.20 192.168.1.30',
      },
    }
  )
end
dhcp_shared_network 'multiple' do
  subnets(
    '192.168.2.0' => {
      'subnet' => '192.168.2.0',
      'netmask' => '255.255.255.0',
      'options' => {
        'broadcast-address' => '192.168.2.255',
        'routers' => '192.168.2.1',
      },
      'pool' => {
        'range' => '192.168.2.20 192.168.2.30',
      },
    },
    '192.168.3.0' => {
      'subnet' => '192.168.3.0',
      'netmask' => '255.255.255.0',
      'options' => {
        'broadcast-address' => '192.168.3.255',
        'routers' => '192.168.3.1',
      },
      'pool' => {
        'range' => [
          '192.168.3.20 192.168.3.30',
          '192.168.3.40 192.168.3.50',
        ],
      },
    }
  )
end