1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
### Autogenerated by dhcp_server.py ###
# For options please consult the following website:
# https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html
#
# log-facility local7;
{% if hostfile_update %}
on release {
set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
set ClientMac = binary-to-ascii(16, 8, ":",substring(hardware, 1, 6));
set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", ClientName, ClientIp, ClientMac, ClientDomain);
}
on expiry {
set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
set ClientMac = binary-to-ascii(16, 8, ":",substring(hardware, 1, 6));
set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", ClientName, ClientIp, ClientMac, ClientDomain);
}
{% endif %}
{% if host_decl_name %}
use-host-decl-names on;
{% endif %}
ddns-update-style {{ 'interim' if ddns_enable else 'none' }};
{% if static_route %}
option rfc3442-static-route code 121 = array of integer 8;
option windows-static-route code 249 = array of integer 8;
{% endif %}
{% if wpad %}
option wpad-url code 252 = text;
{% endif %}
{% if global_parameters %}
# The following {{ global_parameters | length }} line(s) were added as global-parameters in the CLI and have not been validated
{% for param in global_parameters %}
{{ param }}
{% endfor %}
{% endif %}
# Failover configuration
{% for network in shared_network %}
{% if not network.disabled %}
{% for subnet in network.subnet %}
{% if subnet.failover_name %}
failover peer "{{ subnet.failover_name }}" {
{% if subnet.failover_status == 'primary' %}
primary;
mclt 1800;
split 128;
{% elif subnet.failover_status == 'secondary' %}
secondary;
{% endif %}
address {{ subnet.failover_local_addr }};
port 520;
peer address {{ subnet.failover_peer_addr }};
peer port 520;
max-response-delay 30;
max-unacked-updates 10;
load balance max seconds 3;
}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
# Shared network configration(s)
{% for network in shared_network if not network.disabled %}
shared-network {{ network.name }} {
{% if network.authoritative %}
authoritative;
{% endif %}
{% if network.network_parameters %}
# The following {{ network.network_parameters | length }} line(s) were added as shared-network-parameters in the CLI and have not been validated
{% for param in network.network_parameters %}
{{ param }}
{% endfor %}
{% endif %}
{% for subnet in network.subnet %}
subnet {{ subnet.address }} netmask {{ subnet.netmask }} {
{% if subnet.dns_server %}
option domain-name-servers {{ subnet.dns_server | join(', ') }};
{% endif %}
{% if subnet.domain_search %}
option domain-search {{ subnet.domain_search | join(', ') }};
{% endif %}
{% if subnet.ntp_server %}
option ntp-servers {{ subnet.ntp_server | join(', ') }};
{% endif %}
{% if subnet.pop_server %}
option pop-server {{ subnet.pop_server | join(', ') }};
{% endif %}
{% if subnet.smtp_server %}
option smtp-server {{ subnet.smtp_server | join(', ') }};
{% endif %}
{% if subnet.time_server %}
option time-servers {{ subnet.time_server | join(', ') }};
{% endif %}
{% if subnet.wins_server %}
option netbios-name-servers {{ subnet.wins_server | join(', ') }};
{% endif %}
{% if subnet.static_route %}
option rfc3442-static-route {{ subnet.static_route }}{% if subnet.rfc3442_default_router %}, {{ subnet.rfc3442_default_router }}{% endif %};
option windows-static-route {{ subnet.static_route }};
{% endif %}
{% if subnet.ip_forwarding %}
option ip-forwarding true;
{% endif %}
{% if subnet.default_router %}
option routers {{ subnet.default_router }};
{% endif %}
{% if subnet.server_identifier %}
option dhcp-server-identifier {{ subnet.server_identifier }};
{% endif %}
{% if subnet.domain_name %}
option domain-name "{{ subnet.domain_name }}";
{% endif %}
{% if subnet.subnet_parameters %}
# The following {{ subnet.subnet_parameters | length }} line(s) were added as subnet-parameters in the CLI and have not been validated
{% for param in subnet.subnet_parameters %}
{{ param }}
{% endfor %}
{% endif %}
{% if subnet.tftp_server %}
option tftp-server-name "{{ subnet.tftp_server }}";
{% endif %}
{% if subnet.bootfile_name %}
option bootfile-name "{{ subnet.bootfile_name }}";
filename "{{ subnet.bootfile_name }}";
{% endif %}
{% if subnet.bootfile_server %}
next-server {{ subnet.bootfile_server }};
{% endif %}
{% if subnet.time_offset %}
option time-offset {{ subnet.time_offset }};
{% endif %}
{% if subnet.wpad_url %}
option wpad-url "{{ subnet.wpad_url }}";
{% endif %}
{% if subnet.client_prefix_length %}
option subnet-mask {{ subnet.client_prefix_length }};
{% endif %}
{% if subnet.lease %}
default-lease-time {{ subnet.lease }};
max-lease-time {{ subnet.lease }};
{% endif %}
{% for host in subnet.static_mapping if not host.disabled %}
host {% if host_decl_name %} {{ host.name }} {% else %} {{ network.name }}_{{ host.name }} {% endif %} {
{% if host.ip_address %}
fixed-address {{ host.ip_address }};
{% endif %}
hardware ethernet {{ host.mac_address }};
{% if host.static_parameters %}
# The following {{ host.static_parameters | length }} line(s) were added as static-mapping-parameters in the CLI and have not been validated
{% for param in host.static_parameters %}
{{ param }}
{% endfor %}
{% endif %}
}
{% endfor %}
{% if subnet.failover_name %}
pool {
failover peer "{{ subnet.failover_name }}";
deny dynamic bootp clients;
{% for range in subnet.range %}
range {{ range.start }} {{ range.stop }};
{% endfor %}
}
{% else %}
{% for range in subnet.range %}
range {{ range.start }} {{ range.stop }};
{% endfor %}
{% endif %}
}
{% endfor %}
on commit {
set shared-networkname = "{{ network.name }}";
{% if hostfile_update %}
set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
{% endif %}
}
}
{% endfor %}
|