Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
9588cc75
Commit
9588cc75
authored
Feb 15, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Mar 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) cleanup services_dhcpd_configure in services.inc
(cherry picked from commit
14c93845
)
parent
62490b09
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
99 deletions
+94
-99
services.inc
src/etc/inc/services.inc
+94
-99
No files found.
src/etc/inc/services.inc
View file @
9588cc75
...
@@ -410,7 +410,7 @@ function is_dhcp_server_enabled()
...
@@ -410,7 +410,7 @@ function is_dhcp_server_enabled()
{
{
global
$config
;
global
$config
;
if
(
!
is_array
(
$config
[
'dhcpd'
]))
{
if
(
empty
(
$config
[
'dhcpd'
])
||
!
is_array
(
$config
[
'dhcpd'
]))
{
return
false
;
return
false
;
}
}
...
@@ -450,17 +450,10 @@ function services_dhcpdv4_configure()
...
@@ -450,17 +450,10 @@ function services_dhcpdv4_configure()
}
}
}
}
$syscfg
=
$config
[
'system'
];
if
(
!
is_array
(
$config
[
'dhcpd'
]))
{
$config
[
'dhcpd'
]
=
array
();
}
$dhcpdcfg
=
$config
[
'dhcpd'
];
$Iflist
=
get_configured_interface_list
();
/* Only consider DNS servers with IPv4 addresses for the IPv4 DHCP server. */
/* Only consider DNS servers with IPv4 addresses for the IPv4 DHCP server. */
$dns_arrv4
=
array
();
$dns_arrv4
=
array
();
if
(
is_array
(
$syscfg
[
'dnsserver'
]))
{
if
(
!
empty
(
$config
[
'system'
]
[
'dnsserver'
]))
{
foreach
(
$
syscfg
[
'dnsserver'
]
as
$dnsserver
)
{
foreach
(
$
config
[
'system'
]
[
'dnsserver'
]
as
$dnsserver
)
{
if
(
is_ipaddrv4
(
$dnsserver
))
{
if
(
is_ipaddrv4
(
$dnsserver
))
{
$dns_arrv4
[]
=
$dnsserver
;
$dns_arrv4
[]
=
$dnsserver
;
}
}
...
@@ -469,12 +462,10 @@ function services_dhcpdv4_configure()
...
@@ -469,12 +462,10 @@ function services_dhcpdv4_configure()
if
(
file_exists
(
"/var/run/booting"
))
{
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DHCP service..."
);
echo
gettext
(
"Starting DHCP service..."
);
}
else
{
sleep
(
1
);
}
}
$custoptions
=
""
;
$custoptions
=
""
;
foreach
(
$
dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
foreach
(
$
config
[
'dhcpd'
]
as
$dhcpif
=>
$dhcpifconf
)
{
if
(
isset
(
$dhcpifconf
[
'numberoptions'
][
'item'
]))
{
if
(
isset
(
$dhcpifconf
[
'numberoptions'
][
'item'
]))
{
foreach
(
$dhcpifconf
[
'numberoptions'
][
'item'
]
as
$itemidx
=>
$item
)
{
foreach
(
$dhcpifconf
[
'numberoptions'
][
'item'
]
as
$itemidx
=>
$item
)
{
if
(
!
empty
(
$item
[
'type'
]))
{
if
(
!
empty
(
$item
[
'type'
]))
{
...
@@ -488,7 +479,7 @@ function services_dhcpdv4_configure()
...
@@ -488,7 +479,7 @@ function services_dhcpdv4_configure()
}
}
$dhcpdconf
=
<<<EOD
$dhcpdconf
=
<<<EOD
option domain-name "{$
syscfg
['domain']}";
option domain-name "{$
config['system']
['domain']}";
option ldap-server code 95 = text;
option ldap-server code 95 = text;
option domain-search-list code 119 = text;
option domain-search-list code 119 = text;
option arch code 93 = unsigned integer 16; # RFC4578
option arch code 93 = unsigned integer 16; # RFC4578
...
@@ -503,13 +494,6 @@ update-conflict-detection false;
...
@@ -503,13 +494,6 @@ update-conflict-detection false;
EOD;
EOD;
if
(
!
isset
(
$dhcpifconf
[
'disableauthoritative'
]))
{
$dhcpdconf
.=
"authoritative;
\n
"
;
}
if
(
isset
(
$dhcpifconf
[
'alwaysbroadcast'
]))
{
$dhcpdconf
.=
"always-broadcast on
\n
"
;
}
$dhcpdifs
=
array
();
$dhcpdifs
=
array
();
$add_routers
=
false
;
$add_routers
=
false
;
...
@@ -526,20 +510,20 @@ EOD;
...
@@ -526,20 +510,20 @@ EOD;
/* loop through and determine if we need to setup
/* loop through and determine if we need to setup
* failover peer "bleh" entries
* failover peer "bleh" entries
*/
*/
foreach
(
$
dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
foreach
(
$
config
[
'dhcpd'
]
as
$dhcpif
=>
$dhcpifconf
)
{
interfaces_staticarp_configure
(
$dhcpif
);
interfaces_staticarp_configure
(
$dhcpif
);
if
(
!
isset
(
$dhcpifconf
[
'enable'
]))
{
if
(
!
isset
(
$dhcpifconf
[
'enable'
]))
{
continue
;
continue
;
}
}
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'failover_peerip'
])
)
{
$intip
=
get_interface_ip
(
$dhcpif
);
$intip
=
get_interface_ip
(
$dhcpif
);
/*
/*
* yep, failover peer is defined.
* yep, failover peer is defined.
* does it match up to a defined vip?
* does it match up to a defined vip?
*/
*/
$skew
=
110
;
$skew
=
110
;
if
(
is_arra
y
(
$config
[
'virtualip'
][
'vip'
]))
{
if
(
!
empt
y
(
$config
[
'virtualip'
][
'vip'
]))
{
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vipent
)
{
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vipent
)
{
if
(
$vipent
[
'interface'
]
==
$dhcpif
)
{
if
(
$vipent
[
'interface'
]
==
$dhcpif
)
{
$carp_nw
=
gen_subnet
(
$vipent
[
'subnet'
],
$vipent
[
'subnet_bits'
]);
$carp_nw
=
gen_subnet
(
$vipent
[
'subnet'
],
$vipent
[
'subnet_bits'
]);
...
@@ -555,6 +539,7 @@ EOD;
...
@@ -555,6 +539,7 @@ EOD;
}
else
{
}
else
{
log_error
(
gettext
(
"Warning! DHCP Failover setup and no CARP virtual IPs defined!"
));
log_error
(
gettext
(
"Warning! DHCP Failover setup and no CARP virtual IPs defined!"
));
}
}
$dhcpdconf_pri
=
""
;
if
(
$skew
>
10
)
{
if
(
$skew
>
10
)
{
$type
=
"secondary"
;
$type
=
"secondary"
;
$my_port
=
"520"
;
$my_port
=
"520"
;
...
@@ -586,7 +571,8 @@ EOPP;
...
@@ -586,7 +571,8 @@ EOPP;
}
}
}
}
foreach
(
$dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
$Iflist
=
get_configured_interface_list
();
foreach
(
$config
[
'dhcpd'
]
as
$dhcpif
=>
$dhcpifconf
)
{
$newzone
=
array
();
$newzone
=
array
();
$ifcfg
=
$config
[
'interfaces'
][
$dhcpif
];
$ifcfg
=
$config
[
'interfaces'
][
$dhcpif
];
...
@@ -604,24 +590,24 @@ EOPP;
...
@@ -604,24 +590,24 @@ EOPP;
$all_pools
=
array
();
$all_pools
=
array
();
$all_pools
[]
=
$dhcpifconf
;
$all_pools
[]
=
$dhcpifconf
;
if
(
is_array
(
$dhcpifconf
[
'pool'
])
&&
isset
(
$dhcpifconf
[
'pool'
][
'range'
])
)
{
if
(
!
empty
(
$dhcpifconf
[
'pool'
])
)
{
$all_pools
=
array_merge
(
$all_pools
,
$dhcpifconf
[
'pool'
]);
$all_pools
=
array_merge
(
$all_pools
,
$dhcpifconf
[
'pool'
]);
}
}
$dnscfg
=
""
;
$dnscfg
=
""
;
if
(
$dhcpifconf
[
'domain'
]
)
{
if
(
!
empty
(
$dhcpifconf
[
'domain'
])
)
{
$dnscfg
.=
" option domain-name
\"
{
$dhcpifconf
[
'domain'
]
}
\"
;
\n
"
;
$dnscfg
.=
" option domain-name
\"
{
$dhcpifconf
[
'domain'
]
}
\"
;
\n
"
;
}
}
if
(
$dhcpifconf
[
'domainsearchlist'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'domainsearchlist'
])
)
{
$dnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$dhcpifconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
$dnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$dhcpifconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
}
}
if
(
isset
(
$dhcpifconf
[
'ddnsupdate'
]))
{
if
(
isset
(
$dhcpifconf
[
'ddnsupdate'
]))
{
$need_ddns_updates
=
true
;
$need_ddns_updates
=
true
;
$newzone
=
array
();
$newzone
=
array
();
if
(
$dhcpifconf
[
'ddnsdomain'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'ddnsdomain'
])
)
{
$newzone
[
'domain-name'
]
=
$dhcpifconf
[
'ddnsdomain'
];
$newzone
[
'domain-name'
]
=
$dhcpifconf
[
'ddnsdomain'
];
$dnscfg
.=
" ddns-domainname
\"
{
$dhcpifconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
$dnscfg
.=
" ddns-domainname
\"
{
$dhcpifconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
else
{
}
else
{
...
@@ -637,15 +623,15 @@ EOPP;
...
@@ -637,15 +623,15 @@ EOPP;
$newzone
[
'ptr-domain'
]
=
implode
(
"."
,
$revsubnet
)
.
".in-addr.arpa"
;
$newzone
[
'ptr-domain'
]
=
implode
(
"."
,
$revsubnet
)
.
".in-addr.arpa"
;
}
}
if
(
is_array
(
$dhcpifconf
[
'dnsserver'
])
&&
(
$dhcpifconf
[
'dnsserver'
][
0
]))
{
if
(
!
empty
(
$dhcpifconf
[
'dnsserver'
][
0
]))
{
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dhcpifconf
[
'dnsserver'
])
.
";"
;
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dhcpifconf
[
'dnsserver'
])
.
";"
;
if
(
$newzone
[
'domain-name'
]
)
{
if
(
!
empty
(
$newzone
[
'domain-name'
])
)
{
$newzone
[
'dns-servers'
]
=
$dhcpifconf
[
'dnsserver'
];
$newzone
[
'dns-servers'
]
=
$dhcpifconf
[
'dnsserver'
];
}
}
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
])
||
isset
(
$config
[
'unbound'
][
'enable'
]))
{
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
])
||
isset
(
$config
[
'unbound'
][
'enable'
]))
{
$dnscfg
.=
" option domain-name-servers
{
$ifcfgip
}
;"
;
$dnscfg
.=
" option domain-name-servers
{
$ifcfgip
}
;"
;
if
(
$newzone
[
'domain-name'
]
&&
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
{
if
(
$newzone
[
'domain-name'
]
&&
!
empty
(
$config
[
'system'
]
[
'dnsserver'
][
0
]))
{
$newzone
[
'dns-servers'
]
=
$
syscfg
[
'dnsserver'
];
$newzone
[
'dns-servers'
]
=
$
config
[
'system'
]
[
'dnsserver'
];
}
}
}
elseif
(
!
empty
(
$dns_arrv4
))
{
}
elseif
(
!
empty
(
$dns_arrv4
))
{
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dns_arrv4
)
.
";"
;
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dns_arrv4
)
.
";"
;
...
@@ -657,24 +643,23 @@ EOPP;
...
@@ -657,24 +643,23 @@ EOPP;
/* Create classes - These all contain comma separated lists. Join them into one
/* Create classes - These all contain comma separated lists. Join them into one
big comma separated string then split them all up. */
big comma separated string then split them all up. */
$all_mac_strings
=
array
();
$all_mac_strings
=
array
();
if
(
is_array
(
$dhcpifconf
[
'pool'
])
&&
isset
(
$dhcpifconf
[
'pool'
][
'range'
])
)
{
foreach
(
$all_pools
as
$poolconf
)
{
foreach
(
$all_pools
as
$poolconf
)
{
if
(
!
empty
(
$poolconf
[
'mac_allow'
]))
{
$all_mac_strings
[]
=
$poolconf
[
'mac_allow'
];
$all_mac_strings
[]
=
$poolconf
[
'mac_allow'
];
}
if
(
!
empty
(
$poolconf
[
'mac_deny'
]))
{
$all_mac_strings
[]
=
$poolconf
[
'mac_deny'
];
$all_mac_strings
[]
=
$poolconf
[
'mac_deny'
];
}
}
}
}
$all_mac_strings
[]
=
$dhcpifconf
[
'mac_allow'
];
$all_mac_strings
[]
=
$dhcpifconf
[
'mac_deny'
];
$all_mac_list
=
array_unique
(
explode
(
','
,
implode
(
','
,
$all_mac_strings
)));
$all_mac_list
=
array_unique
(
explode
(
','
,
implode
(
','
,
$all_mac_strings
)));
foreach
(
$all_mac_list
as
$mac
)
{
foreach
(
$all_mac_list
as
$mac
)
{
if
(
empty
(
$mac
))
{
if
(
!
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
'class "'
.
str_replace
(
':'
,
''
,
$mac
)
.
'" {'
.
"
\n
"
;
$dhcpdconf
.=
'class "'
.
str_replace
(
':'
,
''
,
$mac
)
.
'" {'
.
"
\n
"
;
// Skip the first octet of the MAC address - for media type, typically Ethernet ("01") and match the rest.
// Skip the first octet of the MAC address - for media type, typically Ethernet ("01") and match the rest.
$dhcpdconf
.=
' match if substring (hardware, 1, '
.
(
substr_count
(
$mac
,
':'
)
+
1
)
.
') = '
.
$mac
.
';'
.
"
\n
"
;
$dhcpdconf
.=
' match if substring (hardware, 1, '
.
(
substr_count
(
$mac
,
':'
)
+
1
)
.
') = '
.
$mac
.
';'
.
"
\n
"
;
$dhcpdconf
.=
'}'
.
"
\n
"
;
$dhcpdconf
.=
'}'
.
"
\n
"
;
}
}
}
$dhcpdconf
.=
"subnet
{
$subnet
}
netmask
{
$subnetmask
}
{\n"
;
$dhcpdconf
.=
"subnet
{
$subnet
}
netmask
{
$subnetmask
}
{\n"
;
...
@@ -682,31 +667,33 @@ EOPP;
...
@@ -682,31 +667,33 @@ EOPP;
foreach
(
$all_pools
as
$poolconf
)
{
foreach
(
$all_pools
as
$poolconf
)
{
$dhcpdconf
.=
" pool {\n"
;
$dhcpdconf
.=
" pool {\n"
;
/* is failover dns setup? */
/* is failover dns setup? */
if
(
is_array
(
$poolconf
[
'dnsserver'
])
&&
$poolconf
[
'dnsserver'
][
0
]
<>
""
)
{
if
(
!
empty
(
$poolconf
[
'dnsserver'
][
0
])
)
{
$dhcpdconf
.=
" option domain-name-servers
{
$poolconf
[
'dnsserver'
][
0
]
}
"
;
$dhcpdconf
.=
" option domain-name-servers
{
$poolconf
[
'dnsserver'
][
0
]
}
"
;
if
(
$poolconf
[
'dnsserver'
][
1
]
<>
""
)
{
if
(
!
empty
(
$poolconf
[
'dnsserver'
][
1
])
)
{
$dhcpdconf
.=
",
{
$poolconf
[
'dnsserver'
][
1
]
}
"
;
$dhcpdconf
.=
",
{
$poolconf
[
'dnsserver'
][
1
]
}
"
;
}
}
$dhcpdconf
.=
";
\n
"
;
$dhcpdconf
.=
";
\n
"
;
}
}
/* allow/deny MACs */
/* allow/deny MACs */
if
(
!
empty
(
$poolconf
[
'mac_allow'
]))
{
$mac_allow_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_allow'
]));
$mac_allow_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_allow'
]));
foreach
(
$mac_allow_list
as
$mac
)
{
foreach
(
$mac_allow_list
as
$mac
)
{
if
(
empty
(
$mac
))
{
if
(
!
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
" allow members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
$dhcpdconf
.=
" allow members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
}
}
}
}
if
(
!
empty
(
$poolconf
[
'mac_deny'
]))
{
$mac_deny_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_deny'
]));
$mac_deny_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_deny'
]));
foreach
(
$mac_deny_list
as
$mac
)
{
foreach
(
$mac_deny_list
as
$mac
)
{
if
(
empty
(
$mac
))
{
if
(
!
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
" deny members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
$dhcpdconf
.=
" deny members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
}
}
}
}
if
(
$poolconf
[
'failover_peerip'
]
<>
""
)
{
if
(
!
empty
(
$poolconf
[
'failover_peerip'
])
)
{
$dhcpdconf
.=
" deny dynamic bootp clients;
\n
"
;
$dhcpdconf
.=
" deny dynamic bootp clients;
\n
"
;
}
}
...
@@ -714,76 +701,86 @@ EOPP;
...
@@ -714,76 +701,86 @@ EOPP;
$dhcpdconf
.=
" deny unknown-clients;
\n
"
;
$dhcpdconf
.=
" deny unknown-clients;
\n
"
;
}
}
if
(
$poolconf
[
'gateway'
]
&&
$poolconf
[
'gateway'
]
!=
"none"
&&
(
$poolconf
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
{
if
(
!
empty
(
$poolconf
[
'gateway'
])
&&
$poolconf
[
'gateway'
]
!=
"none"
&&
(
empty
(
$dhcpifconf
[
'gateway'
])
||
$poolconf
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
])
)
{
$dhcpdconf
.=
" option routers
{
$poolconf
[
'gateway'
]
}
;
\n
"
;
$dhcpdconf
.=
" option routers
{
$poolconf
[
'gateway'
]
}
;
\n
"
;
}
}
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'failover_peerip'
])
)
{
$dhcpdconf
.=
" failover peer
\"
dhcp_
{
$dhcpif
}
\"
;
\n
"
;
$dhcpdconf
.=
" failover peer
\"
dhcp_
{
$dhcpif
}
\"
;
\n
"
;
}
}
$pdnscfg
=
""
;
$pdnscfg
=
""
;
if
(
!
empty
(
$poolconf
[
'domain'
])
if
(
$poolconf
[
'domain'
]
&&
(
$poolconf
[
'domain'
]
!=
$dhcpifconf
[
'domain'
]))
{
&&
(
empty
(
$dhcpifconf
[
'domain'
])
||
$poolconf
[
'domain'
]
!=
$dhcpifconf
[
'domain'
])
)
{
$pdnscfg
.=
" option domain-name
\"
{
$poolconf
[
'domain'
]
}
\"
;
\n
"
;
$pdnscfg
.=
" option domain-name
\"
{
$poolconf
[
'domain'
]
}
\"
;
\n
"
;
}
}
if
(
!
empty
(
$poolconf
[
'domainsearchlist'
])
&&
(
$poolconf
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
if
(
!
empty
(
$poolconf
[
'domainsearchlist'
])
&&
(
empty
(
$dhcpifconf
[
'domainsearchlist'
])
||
$poolconf
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
$pdnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$poolconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
$pdnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$poolconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
}
}
if
(
isset
(
$poolconf
[
'ddnsupdate'
]))
{
if
(
isset
(
$poolconf
[
'ddnsupdate'
]))
{
if
((
$poolconf
[
'ddnsdomain'
]
<>
""
)
&&
(
$poolconf
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
{
if
(
!
empty
(
$poolconf
[
'ddnsdomain'
])
&&
(
empty
(
$dhcpifconf
[
'ddnsdomain'
])
||
$poolconf
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
{
$pdnscfg
.=
" ddns-domainname
\"
{
$poolconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
$pdnscfg
.=
" ddns-domainname
\"
{
$poolconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
}
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
}
}
if
(
is_array
(
$poolconf
[
'dnsserver'
])
&&
(
$poolconf
[
'dnsserver'
][
0
])
&&
(
$poolconf
[
'dnsserver'
][
0
]
!=
$dhcpifconf
[
'dnsserver'
][
0
]))
{
if
(
!
empty
(
$poolconf
[
'dnsserver'
][
0
])
&&
(
empty
(
$dhcpifconf
[
'dnsserver'
][
0
])
||
$poolconf
[
'dnsserver'
][
0
]
!=
$dhcpifconf
[
'dnsserver'
][
0
]))
{
$pdnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$poolconf
[
'dnsserver'
])
.
";
\n
"
;
$pdnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$poolconf
[
'dnsserver'
])
.
";
\n
"
;
}
}
$dhcpdconf
.=
"
{
$pdnscfg
}
"
;
$dhcpdconf
.=
"
{
$pdnscfg
}
"
;
// default-lease-time
// default-lease-time
if
(
$poolconf
[
'defaultleasetime'
]
&&
(
$poolconf
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
if
(
!
empty
(
$poolconf
[
'defaultleasetime'
])
&&
(
empty
(
$dhcpifconf
[
'defaultleasetime'
])
||
$poolconf
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
$dhcpdconf
.=
" default-lease-time
{
$poolconf
[
'defaultleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" default-lease-time
{
$poolconf
[
'defaultleasetime'
]
}
;
\n
"
;
}
}
// max-lease-time
// max-lease-time
if
(
$poolconf
[
'maxleasetime'
]
&&
(
$poolconf
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
if
(
!
empty
(
$poolconf
[
'maxleasetime'
])
&&
(
empty
(
$dhcpifconf
[
'maxleasetime'
])
||
$poolconf
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
$dhcpdconf
.=
" max-lease-time
{
$poolconf
[
'maxleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" max-lease-time
{
$poolconf
[
'maxleasetime'
]
}
;
\n
"
;
}
}
// netbios-name*
// netbios-name*
if
(
is_array
(
$poolconf
[
'winsserver'
])
&&
$poolconf
[
'winsserver'
][
0
]
&&
(
$poolconf
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
if
(
!
empty
(
$poolconf
[
'winsserver'
][
0
])
&&
(
empty
(
$dhcpifconf
[
'winsserver'
][
0
])
||
$poolconf
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$poolconf
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$poolconf
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
}
}
// ntp-servers
// ntp-servers
if
(
is_array
(
$poolconf
[
'ntpserver'
])
&&
$poolconf
[
'ntpserver'
][
0
]
&&
(
$poolconf
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
if
(
!
empty
(
$poolconf
[
'ntpserver'
][
0
])
&&
(
empty
(
$dhcpifconf
[
'ntpserver'
][
0
])
||
$poolconf
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$poolconf
[
'ntpserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$poolconf
[
'ntpserver'
])
.
";
\n
"
;
}
}
// tftp-server-name
// tftp-server-name
if
(
!
empty
(
$poolconf
[
'tftp'
])
&&
(
$poolconf
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
{
if
(
!
empty
(
$poolconf
[
'tftp'
])
&&
(
empty
(
$dhcpifconf
[
'tftp'
])
||
$poolconf
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
{
$dhcpdconf
.=
" option tftp-server-name
\"
{
$poolconf
[
'tftp'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option tftp-server-name
\"
{
$poolconf
[
'tftp'
]
}
\"
;
\n
"
;
}
}
// ldap-server
// ldap-server
if
(
!
empty
(
$poolconf
[
'ldap'
])
&&
(
$poolconf
[
'ldap'
]
!=
$dhcpifconf
[
'ldap'
]))
{
if
(
!
empty
(
$poolconf
[
'ldap'
])
&&
(
empty
(
$dhcpifconf
[
'ldap'
])
||
$poolconf
[
'ldap'
]
!=
$dhcpifconf
[
'ldap'
]))
{
$dhcpdconf
.=
" option ldap-server
\"
{
$poolconf
[
'ldap'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option ldap-server
\"
{
$poolconf
[
'ldap'
]
}
\"
;
\n
"
;
}
}
// net boot information
// net boot information
if
(
isset
(
$poolconf
[
'netboot'
]))
{
if
(
isset
(
$poolconf
[
'netboot'
]))
{
if
(
!
empty
(
$poolconf
[
'nextserver'
])
&&
(
$poolconf
[
'nextserver'
]
!=
$dhcpifconf
[
'nextserver'
]))
{
if
(
!
empty
(
$poolconf
[
'nextserver'
])
&&
(
empty
(
$dhcpifconf
[
'nextserver'
])
||
$poolconf
[
'nextserver'
]
!=
$dhcpifconf
[
'nextserver'
]))
{
$dhcpdconf
.=
" next-server
{
$poolconf
[
'nextserver'
]
}
;
\n
"
;
$dhcpdconf
.=
" next-server
{
$poolconf
[
'nextserver'
]
}
;
\n
"
;
}
}
if
(
!
empty
(
$poolconf
[
'filename'
])
&&
(
$poolconf
[
'filename'
]
!=
$dhcpifconf
[
'filename'
]))
{
if
(
!
empty
(
$poolconf
[
'filename'
])
&&
(
empty
(
$dhcpifconf
[
'filename'
])
||
$poolconf
[
'filename'
]
!=
$dhcpifconf
[
'filename'
]))
{
$dhcpdconf
.=
" filename
\"
{
$poolconf
[
'filename'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" filename
\"
{
$poolconf
[
'filename'
]
}
\"
;
\n
"
;
}
}
if
(
!
empty
(
$poolconf
[
'rootpath'
])
&&
(
$poolconf
[
'rootpath'
]
!=
$dhcpifconf
[
'rootpath'
]))
{
if
(
!
empty
(
$poolconf
[
'rootpath'
])
&&
(
empty
(
$dhcpifconf
[
'rootpath'
])
||
$poolconf
[
'rootpath'
]
!=
$dhcpifconf
[
'rootpath'
]))
{
$dhcpdconf
.=
" option root-path
\"
{
$poolconf
[
'rootpath'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option root-path
\"
{
$poolconf
[
'rootpath'
]
}
\"
;
\n
"
;
}
}
}
}
...
@@ -792,10 +789,10 @@ EOPP;
...
@@ -792,10 +789,10 @@ EOPP;
}
}
// End of settings inside pools
// End of settings inside pools
if
(
$dhcpifconf
[
'gateway'
]
&&
$dhcpifconf
[
'gateway'
]
!=
"none"
)
{
if
(
!
empty
(
$dhcpifconf
[
'gateway'
])
&&
$dhcpifconf
[
'gateway'
]
!=
"none"
)
{
$routers
=
$dhcpifconf
[
'gateway'
];
$routers
=
$dhcpifconf
[
'gateway'
];
$add_routers
=
true
;
$add_routers
=
true
;
}
elseif
(
$dhcpifconf
[
'gateway'
]
==
"none"
)
{
}
elseif
(
!
empty
(
$dhcpifconf
[
'gateway'
])
&&
$dhcpifconf
[
'gateway'
]
==
"none"
)
{
$add_routers
=
false
;
$add_routers
=
false
;
}
else
{
}
else
{
$routers
=
$ifcfgip
;
$routers
=
$ifcfgip
;
...
@@ -809,28 +806,28 @@ $dnscfg
...
@@ -809,28 +806,28 @@ $dnscfg
EOD;
EOD;
// default-lease-time
// default-lease-time
if
(
$dhcpifconf
[
'defaultleasetime'
]
)
{
if
(
!
empty
(
$dhcpifconf
[
'defaultleasetime'
])
)
{
$dhcpdconf
.=
" default-lease-time
{
$dhcpifconf
[
'defaultleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" default-lease-time
{
$dhcpifconf
[
'defaultleasetime'
]
}
;
\n
"
;
}
}
// max-lease-time
// max-lease-time
if
(
$dhcpifconf
[
'maxleasetime'
]
)
{
if
(
!
empty
(
$dhcpifconf
[
'maxleasetime'
])
)
{
$dhcpdconf
.=
" max-lease-time
{
$dhcpifconf
[
'maxleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" max-lease-time
{
$dhcpifconf
[
'maxleasetime'
]
}
;
\n
"
;
}
}
// netbios-name*
// netbios-name*
if
(
is_array
(
$dhcpifconf
[
'winsserver'
])
&&
$dhcpifconf
[
'winsserver'
][
0
]
)
{
if
(
!
empty
(
$dhcpifconf
[
'winsserver'
][
0
])
)
{
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$dhcpifconf
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$dhcpifconf
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
}
}
// ntp-servers
// ntp-servers
if
(
is_array
(
$dhcpifconf
[
'ntpserver'
])
&&
$dhcpifconf
[
'ntpserver'
][
0
]
)
{
if
(
!
empty
(
$dhcpifconf
[
'ntpserver'
][
0
])
)
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$dhcpifconf
[
'ntpserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$dhcpifconf
[
'ntpserver'
])
.
";
\n
"
;
}
}
// tftp-server-name
// tftp-server-name
if
(
$dhcpifconf
[
'tftp'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'tftp'
])
)
{
$dhcpdconf
.=
" option tftp-server-name
\"
{
$dhcpifconf
[
'tftp'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option tftp-server-name
\"
{
$dhcpifconf
[
'tftp'
]
}
\"
;
\n
"
;
}
}
...
@@ -847,13 +844,13 @@ EOD;
...
@@ -847,13 +844,13 @@ EOD;
}
}
// ldap-server
// ldap-server
if
(
$dhcpifconf
[
'ldap'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'ldap'
])
)
{
$dhcpdconf
.=
" option ldap-server
\"
{
$dhcpifconf
[
'ldap'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option ldap-server
\"
{
$dhcpifconf
[
'ldap'
]
}
\"
;
\n
"
;
}
}
// net boot information
// net boot information
if
(
isset
(
$dhcpifconf
[
'netboot'
]))
{
if
(
isset
(
$dhcpifconf
[
'netboot'
]))
{
if
(
$dhcpifconf
[
'nextserver'
]
<>
""
)
{
if
(
!
empty
(
$dhcpifconf
[
'nextserver'
])
)
{
$dhcpdconf
.=
" next-server
{
$dhcpifconf
[
'nextserver'
]
}
;
\n
"
;
$dhcpdconf
.=
" next-server
{
$dhcpifconf
[
'nextserver'
]
}
;
\n
"
;
}
}
if
(
!
empty
(
$dhcpifconf
[
'filename'
])
&&
!
empty
(
$dhcpifconf
[
'filename32'
])
&&
!
empty
(
$dhcpifconf
[
'filename64'
]))
{
if
(
!
empty
(
$dhcpifconf
[
'filename'
])
&&
!
empty
(
$dhcpifconf
[
'filename32'
])
&&
!
empty
(
$dhcpifconf
[
'filename64'
]))
{
...
@@ -878,41 +875,40 @@ EOD;
...
@@ -878,41 +875,40 @@ EOD;
EOD;
EOD;
/* add static mappings */
/* add static mappings */
if
(
is_array
(
$dhcpifconf
[
'staticmap'
]))
{
if
(
!
empty
(
$dhcpifconf
[
'staticmap'
]))
{
$i
=
0
;
foreach
(
$dhcpifconf
[
'staticmap'
]
as
$i
=>
$sm
)
{
foreach
(
$dhcpifconf
[
'staticmap'
]
as
$sm
)
{
$dhcpdconf
.=
"host s_
{
$dhcpif
}
_
{
$i
}
{\n"
;
$dhcpdconf
.=
"host s_
{
$dhcpif
}
_
{
$i
}
{\n"
;
if
(
$sm
[
'mac'
]
)
{
if
(
!
empty
(
$sm
[
'mac'
])
)
{
$dhcpdconf
.=
" hardware ethernet
{
$sm
[
'mac'
]
}
;
\n
"
;
$dhcpdconf
.=
" hardware ethernet
{
$sm
[
'mac'
]
}
;
\n
"
;
}
}
if
(
$sm
[
'cid'
]
)
{
if
(
!
empty
(
$sm
[
'cid'
])
)
{
$dhcpdconf
.=
" option dhcp-client-identifier
\"
{
$sm
[
'cid'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option dhcp-client-identifier
\"
{
$sm
[
'cid'
]
}
\"
;
\n
"
;
}
}
if
(
$sm
[
'ipaddr'
]
)
{
if
(
!
empty
(
$sm
[
'ipaddr'
])
)
{
$dhcpdconf
.=
" fixed-address
{
$sm
[
'ipaddr'
]
}
;
\n
"
;
$dhcpdconf
.=
" fixed-address
{
$sm
[
'ipaddr'
]
}
;
\n
"
;
}
}
if
(
$sm
[
'hostname'
]
)
{
if
(
!
empty
(
$sm
[
'hostname'
])
)
{
$dhhostname
=
str_replace
(
" "
,
"_"
,
$sm
[
'hostname'
]);
$dhhostname
=
str_replace
(
" "
,
"_"
,
$sm
[
'hostname'
]);
$dhhostname
=
str_replace
(
"."
,
"_"
,
$dhhostname
);
$dhhostname
=
str_replace
(
"."
,
"_"
,
$dhhostname
);
$dhcpdconf
.=
" option host-name
\"
{
$dhhostname
}
\"
;
\n
"
;
$dhcpdconf
.=
" option host-name
\"
{
$dhhostname
}
\"
;
\n
"
;
}
}
if
(
$sm
[
'filename'
]
)
{
if
(
!
empty
(
$sm
[
'filename'
])
)
{
$dhcpdconf
.=
" filename
\"
{
$sm
[
'filename'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" filename
\"
{
$sm
[
'filename'
]
}
\"
;
\n
"
;
}
}
if
(
$sm
[
'rootpath'
]
)
{
if
(
!
empty
(
$sm
[
'rootpath'
])
)
{
$dhcpdconf
.=
" option root-path
\"
{
$sm
[
'rootpath'
]
}
\"
;
\n
"
;
$dhcpdconf
.=
" option root-path
\"
{
$sm
[
'rootpath'
]
}
\"
;
\n
"
;
}
}
if
(
$sm
[
'gateway'
]
&&
(
$sm
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
{
if
(
!
empty
(
$sm
[
'gateway'
])
&&
(
$sm
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
{
$dhcpdconf
.=
" option routers
{
$sm
[
'gateway'
]
}
;
\n
"
;
$dhcpdconf
.=
" option routers
{
$sm
[
'gateway'
]
}
;
\n
"
;
}
}
$smdnscfg
=
""
;
$smdnscfg
=
""
;
if
(
$sm
[
'domain'
]
&&
(
$sm
[
'domain'
]
!=
$dhcpifconf
[
'domain'
]))
{
if
(
!
empty
(
$sm
[
'domain'
])
&&
(
$sm
[
'domain'
]
!=
$dhcpifconf
[
'domain'
]))
{
$smdnscfg
.=
" option domain-name
\"
{
$sm
[
'domain'
]
}
\"
;
\n
"
;
$smdnscfg
.=
" option domain-name
\"
{
$sm
[
'domain'
]
}
\"
;
\n
"
;
}
}
...
@@ -927,29 +923,29 @@ EOD;
...
@@ -927,29 +923,29 @@ EOD;
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
}
}
if
(
is_arra
y
(
$sm
[
'dnsserver'
])
&&
(
$sm
[
'dnsserver'
][
0
])
&&
(
$sm
[
'dnsserver'
][
0
]
!=
$dhcpifconf
[
'dnsserver'
][
0
]))
{
if
(
!
empt
y
(
$sm
[
'dnsserver'
])
&&
(
$sm
[
'dnsserver'
][
0
])
&&
(
$sm
[
'dnsserver'
][
0
]
!=
$dhcpifconf
[
'dnsserver'
][
0
]))
{
$smdnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$sm
[
'dnsserver'
])
.
";
\n
"
;
$smdnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$sm
[
'dnsserver'
])
.
";
\n
"
;
}
}
$dhcpdconf
.=
"
{
$smdnscfg
}
"
;
$dhcpdconf
.=
"
{
$smdnscfg
}
"
;
// default-lease-time
// default-lease-time
if
(
$sm
[
'defaultleasetime'
]
&&
(
$sm
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
if
(
!
empty
(
$sm
[
'defaultleasetime'
])
&&
(
$sm
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
$dhcpdconf
.=
" default-lease-time
{
$sm
[
'defaultleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" default-lease-time
{
$sm
[
'defaultleasetime'
]
}
;
\n
"
;
}
}
// max-lease-time
// max-lease-time
if
(
$sm
[
'maxleasetime'
]
&&
(
$sm
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
if
(
!
empty
(
$sm
[
'maxleasetime'
])
&&
(
$sm
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
$dhcpdconf
.=
" max-lease-time
{
$sm
[
'maxleasetime'
]
}
;
\n
"
;
$dhcpdconf
.=
" max-lease-time
{
$sm
[
'maxleasetime'
]
}
;
\n
"
;
}
}
// netbios-name*
// netbios-name*
if
(
is_arra
y
(
$sm
[
'winsserver'
])
&&
$sm
[
'winsserver'
][
0
]
&&
(
$sm
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
if
(
!
empt
y
(
$sm
[
'winsserver'
])
&&
$sm
[
'winsserver'
][
0
]
&&
(
$sm
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$sm
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-name-servers "
.
join
(
","
,
$sm
[
'winsserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
$dhcpdconf
.=
" option netbios-node-type 8;
\n
"
;
}
}
// ntp-servers
// ntp-servers
if
(
is_arra
y
(
$sm
[
'ntpserver'
])
&&
$sm
[
'ntpserver'
][
0
]
&&
(
$sm
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
if
(
!
empt
y
(
$sm
[
'ntpserver'
])
&&
$sm
[
'ntpserver'
][
0
]
&&
(
$sm
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$sm
[
'ntpserver'
])
.
";
\n
"
;
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$sm
[
'ntpserver'
])
.
";
\n
"
;
}
}
...
@@ -959,12 +955,11 @@ EOD;
...
@@ -959,12 +955,11 @@ EOD;
}
}
$dhcpdconf
.=
"}
\n
"
;
$dhcpdconf
.=
"}
\n
"
;
$i
++
;
}
}
}
}
$dhcpdifs
[]
=
get_real_interface
(
$dhcpif
);
$dhcpdifs
[]
=
get_real_interface
(
$dhcpif
);
if
(
$newzone
[
'domain-name'
]
)
{
if
(
!
empty
(
$newzone
[
'domain-name'
])
)
{
if
(
$need_ddns_updates
)
{
if
(
$need_ddns_updates
)
{
$newzone
[
'dns-servers'
]
=
array
(
$dhcpifconf
[
'ddnsdomainprimary'
]);
$newzone
[
'dns-servers'
]
=
array
(
$dhcpifconf
[
'ddnsdomainprimary'
]);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment