1
|
########################################################
|
2
|
#
|
3
|
## dhcpd.conf pour ScribeNg
|
4
|
#
|
5
|
## Equipe Eole eole@ac-dijon.fr
|
6
|
#
|
7
|
## septembre 2007
|
8
|
#
|
9
|
########################################################
|
10
|
#
|
11
|
%if not %%is_empty(%%global_dhcp_lease_default)
|
12
|
default-lease-time %%global_dhcp_lease_default;
|
13
|
%end if
|
14
|
%if not %%is_empty(%%global_dhcp_lease_max)
|
15
|
max-lease-time %%global_dhcp_lease_max;
|
16
|
%end if
|
17
|
%if not %%is_empty(%%global_nom_domaine_dhcp)
|
18
|
option domain-name "%%global_nom_domaine_dhcp";
|
19
|
%end if
|
20
|
%if not %%is_empty(%%global_adresse_ip_dns_dhcp)
|
21
|
%set %%dns_ip = %%global_adresse_ip_dns_dhcp
|
22
|
%if not %%is_empty(%%global_adresse_ip_dns_secondaire_dhcp)
|
23
|
%set %%dns_ip = %%dns_ip + ', ' + %%global_adresse_ip_dns_secondaire_dhcp
|
24
|
%end if
|
25
|
option domain-name-servers %%dns_ip;
|
26
|
%end if
|
27
|
%if not %%is_empty(%%global_adresse_ip_wins_primaire_dhcp)
|
28
|
%set %%netbios_ip = %%global_adresse_ip_wins_primaire_dhcp
|
29
|
%if not %%is_empty(%%global_adresse_ip_wins_secondaire_dhcp)
|
30
|
%set %%netbios_ip = %%netbios_ip + ', ' + %%global_adresse_ip_wins_secondaire_dhcp
|
31
|
%end if
|
32
|
option netbios-name-servers %%netbios_ip;
|
33
|
option netbios-dd-server %%netbios_ip;
|
34
|
option netbios-node-type 8;
|
35
|
%end if
|
36
|
%if not %%is_empty(%%global_adresse_ip_ntp_dhcp)
|
37
|
option ntp-servers %%global_adresse_ip_ntp_dhcp;
|
38
|
%end if
|
39
|
%if not %%is_empty(%%global_domain_wpad_dhcp)
|
40
|
option wpad-url code 252 = text;
|
41
|
option wpad-url "http://wpad.%%global_domain_wpad_dhcp/wpad.dat\n";
|
42
|
%end if
|
43
|
|
44
|
#ToIP
|
45
|
%if %%global_verif_modele_telip_dhcp == "oui"
|
46
|
## Vérification des id vendor dans le fichier des baux
|
47
|
set vendor-string = option vendor-class-identifier;
|
48
|
%end if
|
49
|
## définition des espaces d'option Tel.IP
|
50
|
%if not %%is_empty(%%global_modele_telip_dhcp)
|
51
|
%for %%i_modele in %%global_modele_telip_dhcp
|
52
|
option space %%i_modele code width 1 length width 1 hash size 3;
|
53
|
%set %%optprio = %%i_modele +'.vendor-priority'
|
54
|
%set %%optvlan = %%i_modele +'.vendor-vlan-id'
|
55
|
option %%optprio code %%i_modele.global_option_vendor_priority_dhcp = unsigned integer 8;
|
56
|
option %%optvlan code %%i_modele.global_option_vendor_vlanid_dhcp = unsigned integer 16;
|
57
|
%end for
|
58
|
%end if
|
59
|
|
60
|
#ddns-update-style none;
|
61
|
authoritative;
|
62
|
|
63
|
%if %%adresse_network_eth0 not in %%adresse_network_dhcp
|
64
|
# pas de dhcp sur la zone scribe
|
65
|
subnet %%adresse_network_eth0 netmask %%adresse_netmask_eth0 {
|
66
|
}
|
67
|
%end if
|
68
|
|
69
|
%set %%subnets = {}
|
70
|
%for %%subnet in %%adresse_network_dhcp
|
71
|
%silent %%subnets.setdefault((%%str(%%subnet), %%subnet.adresse_netmask_dhcp),{})
|
72
|
%set %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('ranges', {})[(%%subnet.ip_basse_dhcp, %%subnet.ip_haute_dhcp)] = {'restriction': %%subnet.interdire_hotes_inconnus, 'lease_default': %%subnet.dhcp_lease_default, 'lease_max': %%subnet.dhcp_lease_max}
|
73
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('dns', [])
|
74
|
%if %%subnet.adresse_ip_dns_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['dns']
|
75
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('dns', []).append(%%subnet.adresse_ip_dns_dhcp)
|
76
|
%end if
|
77
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('dns', [])
|
78
|
%if %%subnet.adresse_ip_dns_secondaire_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['dns']
|
79
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('dns', []).append(%%subnet.adresse_ip_dns_secondaire_dhcp)
|
80
|
%end if
|
81
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('domain', [])
|
82
|
%if %%subnet.nom_domaine_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['domain']
|
83
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('domain', []).append(%%subnet.nom_domaine_dhcp)
|
84
|
%end if
|
85
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('gateway', [])
|
86
|
%if %%subnet.adresse_ip_gw_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['gateway']
|
87
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('gateway', []).append(%%subnet.adresse_ip_gw_dhcp)
|
88
|
%end if
|
89
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('ntp', [])
|
90
|
%if %%subnet.adresse_ip_ntp_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['ntp']
|
91
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('ntp', []).append(%%subnet.adresse_ip_ntp_dhcp)
|
92
|
%end if
|
93
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('wins', [])
|
94
|
%if %%subnet.adresse_ip_wins_primaire_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['wins']
|
95
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('wins', []).append(%%subnet.adresse_ip_wins_primaire_dhcp)
|
96
|
%end if
|
97
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('wins', [])
|
98
|
%if %%subnet.adresse_ip_wins_secondaire_dhcp not in %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)]['wins']
|
99
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('wins', []).append(%%subnet.adresse_ip_wins_secondaire_dhcp)
|
100
|
%end if
|
101
|
|
102
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('vendor', []).append(%%subnet.vendor_identifier_dhcp)
|
103
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('priority', []).append(%%subnet.vendor_priority_dhcp)
|
104
|
%silent %%subnets[(%%str(%%subnet), %%subnet.adresse_netmask_dhcp)].setdefault('vlanid', []).append(%%subnet.vendor_vlanid_dhcp)
|
105
|
|
106
|
%end for
|
107
|
%for %%subnet in %%subnets
|
108
|
subnet %%subnet[0] netmask %%subnet[1] {
|
109
|
%set %%gateway = [g for g in %%subnets[%%subnet]['gateway'] if g != None]
|
110
|
%if not %%len(%%gateway) == 0
|
111
|
option routers %%custom_join(%%gateway, ' ');
|
112
|
%end if
|
113
|
option subnet-mask %%subnet[1];
|
114
|
%set %%domain = [g for g in %%subnets[%%subnet]['domain'] if g != None]
|
115
|
%if not %%len(%%domain) == 0
|
116
|
option domain-name "%%domain[0]";
|
117
|
%end if
|
118
|
%set %%dns = [d for d in %%subnets[%%subnet]['dns'] if d != None]
|
119
|
%if not %%len(%%dns) == 0
|
120
|
option domain-name-servers %%custom_join(%%dns, ', ');
|
121
|
%end if
|
122
|
%set %%wins = [d for d in %%subnets[%%subnet]['wins'] if d != None]
|
123
|
%if %%len(%%wins) == 0 and %%is_defined('container_ip_fichier')
|
124
|
%if %%container_ip_fichier == "127.0.0.1"
|
125
|
option netbios-name-servers %%adresse_ip_eth0;
|
126
|
option netbios-dd-server %%adresse_ip_eth0;
|
127
|
option netbios-node-type 8;
|
128
|
%else
|
129
|
option netbios-name-servers %%adresse_ip_fichier_link;
|
130
|
option netbios-dd-server %%adresse_ip_fichier_link;
|
131
|
option netbios-node-type 8;
|
132
|
%end if
|
133
|
%elif not %%len(%%wins) == 0
|
134
|
option netbios-name-servers %%custom_join(%%wins, ', ');
|
135
|
option netbios-dd-server %%custom_join(%%wins, ', ');
|
136
|
option netbios-node-type 8;
|
137
|
%end if
|
138
|
|
139
|
# dhcp statique
|
140
|
include "/etc/dhcp/fixed-address/%%{subnet[0]}_%%{subnet[1]}.txt";
|
141
|
|
142
|
#serveur de temps
|
143
|
%set %%ntp = [d for d in %%subnets[%%subnet]['ntp'] if d != None]
|
144
|
%if not %%len(%%ntp) == 0
|
145
|
option ntp-servers %%custom_join(%%ntp, ', ');
|
146
|
%else
|
147
|
option ntp-servers %%adresse_ip_eth0;
|
148
|
%end if
|
149
|
|
150
|
%if %%activer_tftp == 'oui'
|
151
|
next-server %%adresse_ip_tftp;
|
152
|
filename "%%chemin_fichier_pxe";
|
153
|
%end if
|
154
|
|
155
|
%set %%vendor = [v for v in %%subnets[%%subnet]['vendor'] if v != None]
|
156
|
%if not %%len(%%dns) == 0
|
157
|
%set %%modele = %%custom_join(%%global_modele_telip_dhcp, ' ')
|
158
|
%set %%optprio = %%modele +'.vendor-priority'
|
159
|
%set %%optvlan = %%modele +'.vendor-vlan-id'
|
160
|
class "vendor-class-%%modele" {
|
161
|
match if option vendor-class-identifier="%%custom_join(%%vendor, ' ')";
|
162
|
vendor-option-space %%modele;
|
163
|
%set %%priority = [p for p in %%subnets[%%subnet]['priority'] if p != None]
|
164
|
%if not %%len(%%priority) == 0
|
165
|
option %%optprio %%custom_join(%%priority, ' ');
|
166
|
%end if
|
167
|
%set %%vlanid = [l for l in %%subnets[%%subnet]['vlanid'] if l != None]
|
168
|
%if not %%len(%%vlanid) == 0
|
169
|
option %%optvlan %%custom_join(%%vlanid, ' ');
|
170
|
%end if
|
171
|
}
|
172
|
%end if
|
173
|
|
174
|
%set %%nb_ranges = %%len(%%subnets[%%subnet]['ranges'])
|
175
|
%for %%range_ip in %%subnets[%%subnet]['ranges']
|
176
|
%if %%nb_ranges > 1
|
177
|
# plages d'ip
|
178
|
pool {
|
179
|
range %%range_ip[0] %%range_ip[1];
|
180
|
%if %%subnets[%%subnet]['ranges'][%%range_ip]['restriction'] == 'oui'
|
181
|
deny unknown-clients;
|
182
|
%end if
|
183
|
%set %%lease_default = %%subnets[%%subnet]['ranges'][%%range_ip]['lease_default']
|
184
|
%if not %%lease_default == None
|
185
|
default-lease-time %%lease_default;
|
186
|
%end if
|
187
|
%set %%lease_max = %%subnets[%%subnet]['ranges'][%%range_ip]['lease_max']
|
188
|
%if not %%lease_max == None
|
189
|
max-lease-time %%lease_max;
|
190
|
%end if
|
191
|
}
|
192
|
%else
|
193
|
# plages d'ip
|
194
|
%set %%lease_default = %%subnets[%%subnet]['ranges'][%%range_ip]['lease_default']
|
195
|
%if not %%lease_default == None
|
196
|
default-lease-time %%lease_default;
|
197
|
%end if
|
198
|
%set %%lease_max = %%subnets[%%subnet]['ranges'][%%range_ip]['lease_max']
|
199
|
%if not %%lease_max == None
|
200
|
max-lease-time %%lease_max;
|
201
|
%end if
|
202
|
range %%range_ip[0] %%range_ip[1];
|
203
|
%if %%subnets[%%subnet]['ranges'][%%range_ip]['restriction'] == 'oui'
|
204
|
deny unknown-clients;
|
205
|
%end if
|
206
|
%end if
|
207
|
|
208
|
|
209
|
%end for
|
210
|
}
|
211
|
|
212
|
%end for
|