2020-11-15 11:00:58 +00:00
|
|
|
<%
|
2021-04-20 16:17:52 +00:00
|
|
|
import re
|
|
|
|
from ipaddress import ip_network
|
2020-11-13 22:30:21 +00:00
|
|
|
%>
|
2020-11-13 21:11:56 +00:00
|
|
|
ddns-update-style none;
|
|
|
|
|
|
|
|
authoritative;
|
|
|
|
|
2021-04-20 16:17:52 +00:00
|
|
|
% for interface, subnet in sorted(dhcp_config.get('subnets', {}).items()):
|
|
|
|
<%
|
|
|
|
network = ip_network(subnet['subnet'])
|
|
|
|
%>
|
|
|
|
# interface ${interface} provides ${subnet['subnet']}
|
|
|
|
subnet ${network.network_address} netmask ${network.netmask} {
|
2020-11-15 11:00:58 +00:00
|
|
|
% if subnet.get('range_lower', None) and subnet.get('range_higher', None):
|
2020-11-13 21:11:56 +00:00
|
|
|
range ${subnet['range_lower']} ${subnet['range_higher']};
|
2020-11-15 11:00:58 +00:00
|
|
|
% endif
|
2021-04-20 16:17:52 +00:00
|
|
|
interface "${interface}";
|
2020-11-13 21:11:56 +00:00
|
|
|
default-lease-time ${subnet.get('default-lease-time', 600)};
|
|
|
|
max-lease-time ${subnet.get('max-lease-time', 3600)};
|
2020-11-15 11:00:58 +00:00
|
|
|
% for option, value in sorted(subnet.get('options', {}).items()):
|
|
|
|
% if re.match('([^0-9\.,\ ])', value):
|
|
|
|
option ${option} "${value}";
|
|
|
|
% else:
|
|
|
|
option ${option} ${value};
|
|
|
|
% endif
|
|
|
|
% endfor
|
2020-11-13 21:11:56 +00:00
|
|
|
}
|
|
|
|
% endfor
|
|
|
|
|
|
|
|
% for identifier, allocation in dhcp_config.get('fixed_allocations', {}).items():
|
|
|
|
host ${identifier} {
|
|
|
|
hardware ethernet ${allocation['mac']};
|
|
|
|
fixed-address ${allocation['ipv4']};
|
|
|
|
}
|
|
|
|
% endfor
|