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
2ca72533
Commit
2ca72533
authored
Nov 23, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dnsmasq: domain override for dynamic dhcp lease registration
PR:
https://github.com/opnsense/core/issues/1250
parent
24c86337
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
dnsmasq.inc
src/etc/inc/plugins.inc.d/dnsmasq.inc
+3
-0
services_dnsmasq.php
src/www/services_dnsmasq.php
+25
-6
No files found.
src/etc/inc/plugins.inc.d/dnsmasq.inc
View file @
2ca72533
...
@@ -273,6 +273,9 @@ function dnsmasq_hosts_generate()
...
@@ -273,6 +273,9 @@ function dnsmasq_hosts_generate()
if
(
isset
(
$config
[
'dnsmasq'
][
'regdhcp'
])
&&
file_exists
(
$leases
))
{
if
(
isset
(
$config
[
'dnsmasq'
][
'regdhcp'
])
&&
file_exists
(
$leases
))
{
$domain
=
$config
[
'system'
][
'domain'
];
$domain
=
$config
[
'system'
][
'domain'
];
if
(
isset
(
$config
[
'dnsmasq'
][
'regdhcpdomain'
]))
{
$domain
=
$config
[
'dnsmasq'
][
'regdhcpdomain'
];
}
mwexecf
(
mwexecf
(
'/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s'
,
'/usr/local/sbin/dhcpleases -l %s -d %s -p %s -h %s'
,
array
(
$leases
,
$domain
,
'/var/run/dnsmasq.pid'
,
'/var/etc/dnsmasq-hosts'
)
array
(
$leases
,
$domain
,
'/var/run/dnsmasq.pid'
,
'/var/etc/dnsmasq-hosts'
)
...
...
src/www/services_dnsmasq.php
View file @
2ca72533
...
@@ -46,6 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -46,6 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// booleans
// booleans
$pconfig
[
'enable'
]
=
isset
(
$config
[
'dnsmasq'
][
'enable'
]);
$pconfig
[
'enable'
]
=
isset
(
$config
[
'dnsmasq'
][
'enable'
]);
$pconfig
[
'regdhcp'
]
=
isset
(
$config
[
'dnsmasq'
][
'regdhcp'
]);
$pconfig
[
'regdhcp'
]
=
isset
(
$config
[
'dnsmasq'
][
'regdhcp'
]);
$pconfig
[
'regdhcpdomain'
]
=
!
empty
(
$config
[
'dnsmasq'
][
'regdhcpdomain'
])
?
$config
[
'dnsmasq'
][
'regdhcpdomain'
]
:
null
;
$pconfig
[
'regdhcpstatic'
]
=
isset
(
$config
[
'dnsmasq'
][
'regdhcpstatic'
]);
$pconfig
[
'regdhcpstatic'
]
=
isset
(
$config
[
'dnsmasq'
][
'regdhcpstatic'
]);
$pconfig
[
'dhcpfirst'
]
=
isset
(
$config
[
'dnsmasq'
][
'dhcpfirst'
]);
$pconfig
[
'dhcpfirst'
]
=
isset
(
$config
[
'dnsmasq'
][
'dhcpfirst'
]);
$pconfig
[
'strict_order'
]
=
isset
(
$config
[
'dnsmasq'
][
'strict_order'
]);
$pconfig
[
'strict_order'
]
=
isset
(
$config
[
'dnsmasq'
][
'strict_order'
]);
...
@@ -63,6 +64,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -63,6 +64,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors
=
array
();
$input_errors
=
array
();
if
(
isset
(
$pconfig
[
'submit'
]))
{
if
(
isset
(
$pconfig
[
'submit'
]))
{
// validate
// validate
if
(
!
empty
(
$pconfig
[
'regdhcpdomain'
])
&&
!
is_domain
(
$pconfig
[
'regdhcpdomain'
]))
{
$input_errors
[]
=
gettext
(
"The domain may only contain the characters a-z, 0-9, '-' and '.'."
);
}
if
(
!
empty
(
$pconfig
[
'port'
])
&&
!
is_port
(
$pconfig
[
'port'
]))
{
if
(
!
empty
(
$pconfig
[
'port'
])
&&
!
is_port
(
$pconfig
[
'port'
]))
{
$input_errors
[]
=
gettext
(
"You must specify a valid port number"
);
$input_errors
[]
=
gettext
(
"You must specify a valid port number"
);
}
}
...
@@ -91,9 +95,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -91,9 +95,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$config
[
'dnsmasq'
][
'domain_needed'
]
=
!
empty
(
$pconfig
[
'domain_needed'
]);
$config
[
'dnsmasq'
][
'domain_needed'
]
=
!
empty
(
$pconfig
[
'domain_needed'
]);
$config
[
'dnsmasq'
][
'no_private_reverse'
]
=
!
empty
(
$pconfig
[
'no_private_reverse'
]);
$config
[
'dnsmasq'
][
'no_private_reverse'
]
=
!
empty
(
$pconfig
[
'no_private_reverse'
]);
$config
[
'dnsmasq'
][
'strictbind'
]
=
!
empty
(
$pconfig
[
'strictbind'
]);
$config
[
'dnsmasq'
][
'strictbind'
]
=
!
empty
(
$pconfig
[
'strictbind'
]);
if
(
!
empty
(
$pconfig
[
'regdhcpdomain'
]))
{
$config
[
'dnsmasq'
][
'regdhcpdomain'
]
=
$pconfig
[
'regdhcpdomain'
];
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'regdhcpdomain'
]))
{
unset
(
$config
[
'dnsmasq'
][
'regdhcpdomain'
]);
}
if
(
!
empty
(
$pconfig
[
'interface'
]))
{
if
(
!
empty
(
$pconfig
[
'interface'
]))
{
$config
[
'dnsmasq'
][
'interface'
]
=
implode
(
","
,
$pconfig
[
'interface'
]);
$config
[
'dnsmasq'
][
'interface'
]
=
implode
(
","
,
$pconfig
[
'interface'
]);
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'interface'
]))
{
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'interface'
]))
{
unset
(
$config
[
'dnsmasq'
][
'interface'
]);
unset
(
$config
[
'dnsmasq'
][
'interface'
]);
}
}
if
(
!
empty
(
$pconfig
[
'port'
]))
{
if
(
!
empty
(
$pconfig
[
'port'
]))
{
...
@@ -244,11 +253,21 @@ $( document ).ready(function() {
...
@@ -244,11 +253,21 @@ $( document ).ready(function() {
<input
name=
"regdhcp"
type=
"checkbox"
id=
"regdhcp"
value=
"yes"
<?=
!
empty
(
$pconfig
[
'regdhcp'
])
?
"checked=
\"
checked
\"
"
:
""
;
?>
/>
<input
name=
"regdhcp"
type=
"checkbox"
id=
"regdhcp"
value=
"yes"
<?=
!
empty
(
$pconfig
[
'regdhcp'
])
?
"checked=
\"
checked
\"
"
:
""
;
?>
/>
<strong>
<?=
gettext
(
"Register DHCP leases in DNS forwarder"
);
?>
</strong>
<strong>
<?=
gettext
(
"Register DHCP leases in DNS forwarder"
);
?>
</strong>
<div
class=
"hidden"
for=
"help_for_regdhcp"
>
<div
class=
"hidden"
for=
"help_for_regdhcp"
>
<?=
sprintf
(
gettext
(
"If this option is set, then machines that specify"
.
<?=
gettext
(
"If this option is set, then machines that specify "
.
" their hostname when requesting a DHCP lease will be registered"
.
"their hostname when requesting a DHCP lease will be registered "
.
" in the DNS forwarder, so that their name can be resolved."
.
"in the DNS forwarder, so that their name can be resolved."
)
?>
" You should also set the domain in %sSystem:"
.
</div>
" General setup%s to the proper value."
),
'<a href="system_general.php">'
,
'</a>'
)
?>
</td>
</tr>
<tr>
<td><a
id=
"help_for_regdhcpdomain"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"DHCP Domain Override"
);
?>
</td>
<td>
<input
name=
"regdhcpdomain"
type=
"text"
id=
"regdhcpdomain"
value=
"
<?=
$pconfig
[
'regdhcpdomain'
]
?>
"
/>
<div
class=
"hidden"
for=
"help_for_regdhcpdomain"
>
<?=
gettext
(
"The domain name to use for DHCP hostname registration. "
.
"If empty, the default system domain is used. Note that all DHCP "
.
"leases will be assigned to the same domain. If this is undesired, "
.
"static DHCP lease registration is able to provide coherent mappings."
)
?>
</div>
</div>
</td>
</td>
</tr>
</tr>
...
...
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