Last active
May 1, 2019 00:29
-
-
Save valentinbud/7132291 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ pillar['warnings']['master'] }} | |
# | |
# Sample configuration file for ISC dhcpd for Debian | |
# | |
# | |
# The ddns-updates-style parameter controls whether or not the server will | |
# attempt to do a DNS update when a lease is confirmed. We default to the | |
# behavior of the version 2 packages ('none', since DHCP v2 didn't | |
# have support for DDNS.) | |
ddns-updates on; | |
ddns-update-style interim; | |
ddns-ttl 60; | |
ignore client-updates; | |
update-static-leases on; | |
update-conflict-detection off; | |
do-forward-updates on; | |
# option definitions common to all supported networks... | |
default-lease-time -1; | |
max-lease-time -1; | |
min-lease-time -1; | |
# If this DHCP server is the official DHCP server for the local | |
# network, the authoritative directive should be uncommented. | |
authoritative; | |
# Use this to send dhcp log messages to a different log file (you also | |
# have to hack syslog.conf to complete the redirection). | |
log-facility local7; | |
### DDNS KEY | |
include "/etc/dhcp/ddns.key"; | |
{% set host = pillar.get(grains['id'],{}) -%} | |
{% set host_networks = host.get('network', {}) -%} | |
{% set interfaces = host_networks.get('interfaces', {}) -%} | |
{% for id,virbr in interfaces.items() -%} | |
{% if virbr['up'] == True and virbr['dhcp'] -%} | |
{% set nets = pillar.get('networks', {}) %} | |
{% set dns_master = nets.get('dns-master', {}) %} | |
{% set dns_master_ip = dns_master['ip'] %} | |
{% set dns_resolver = nets.get('dns-resolver', {}) %} | |
{% set dns_resolver_anycast = dns_resolver.get('anycast', {}) %} | |
{% set dns_resolver_ip = dns_resolver_anycast['ip'] %} | |
{% set inet = virbr.get('inet',{}) -%} | |
{% set label = inet['label'] -%} | |
{% set address = inet['address'] -%} | |
{% set netmask = inet['netmask'] -%} | |
{% set broadcast = inet['broadcast'] -%} | |
{% set gateway = inet['gateway'] -%} | |
{% set cidr = inet['cidr'] -%} | |
{% set cidr_split = cidr.split('/')[0] -%} | |
{% set reverse_ip = cidr_split.split('.')[0:3] | reverse | join('.') -%} | |
{% set dhcp = virbr.get('dhcp',{}) %} | |
{% set dhcp_range = dhcp['range'] %} | |
{% set dhcp_domain = dhcp['domain-name'] %} | |
### SUBNETS | |
subnet {{ cidr.split('/')[0] }} netmask {{ netmask }} { | |
range {{ dhcp_range }}; | |
option domain-name-servers {{ dns_resolver_ip }}; | |
option domain-name "{{ dhcp_domain }}"; | |
option routers {{ gateway }}; | |
option broadcast-address {{ broadcast }}; | |
} | |
### DYNAMIC ZONES | |
zone {{ dhcp_domain }}. { | |
primary 192.168.0.100; | |
key DDNS_UPDATE; | |
} | |
zone {{ reverse_ip }}.in-addr.arpa. { | |
primary 192.168.0.100; | |
key DDNS_UPDATE; | |
} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment