mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
Services: Kea DHCP [new]: Kea DHCPv4 - add optional automatic firewall rules for dhcpv4 access. closes https://github.com/opnsense/core/issues/7188
This commit is contained in:
parent
46e0bc67bb
commit
b1685d8e46
@ -54,6 +54,45 @@ function kea_syslog()
|
||||
}
|
||||
|
||||
|
||||
function kea_firewall($fw)
|
||||
{
|
||||
global $config;
|
||||
$keav4 = new \OPNsense\Kea\KeaDhcpv4();
|
||||
if ($keav4->fwrulesEnabled()) {
|
||||
// automatic (IPv4) rules enabled
|
||||
foreach (explode(',', $keav4->general->interfaces) as $intf) {
|
||||
$fw->registerFilterRule(
|
||||
1,
|
||||
[
|
||||
'protocol' => 'udp',
|
||||
'direction' => 'in',
|
||||
'from_port' => 68,
|
||||
'to' => '255.255.255.255',
|
||||
'#ref' => 'ui/kea/dhcp/v4',
|
||||
'to_port' => 67,
|
||||
'interface' => $intf,
|
||||
'descr' => 'allow access to DHCP server',
|
||||
'log' => !isset($config['syslog']['nologdefaultpass'])
|
||||
]
|
||||
);
|
||||
$fw->registerFilterRule(
|
||||
1,
|
||||
[
|
||||
'protocol' => 'udp',
|
||||
'direction' => 'in',
|
||||
'from_port' => 68,
|
||||
'to' => '(self)',
|
||||
'#ref' => 'ui/kea/dhcp/v4',
|
||||
'to_port' => 67,
|
||||
'interface' => $intf,
|
||||
'descr' => 'allow access to DHCP server',
|
||||
'log' => !isset($config['syslog']['nologdefaultpass'])
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function kea_xmlrpc_sync()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@ -21,6 +21,12 @@
|
||||
<type>text</type>
|
||||
<help>Defines how long the addresses (leases) given out by the server are valid (in seconds)</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>dhcpv4.general.fwrules</id>
|
||||
<label>Firewall rules</label>
|
||||
<type>checkbox</type>
|
||||
<help>Automatically add a basic set of firewall rules to allow dhcp traffic, more fine grained controls can be offered manually when disabling this option.</help>
|
||||
</field>
|
||||
<field>
|
||||
<type>header</type>
|
||||
<label>High Availability</label>
|
||||
|
||||
@ -65,4 +65,15 @@ class KeaDhcpv4 extends BaseModel
|
||||
}
|
||||
return parent::setNodes($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* should filter rules be enabled
|
||||
* @return bool
|
||||
*/
|
||||
public function fwrulesEnabled()
|
||||
{
|
||||
return (string)$this->general->enabled == '1' &&
|
||||
(string)$this->general->fwrules == '1' &&
|
||||
!empty((string)(string)$this->general->interfaces);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<model>
|
||||
<mount>//OPNsense/Kea/dhcp4</mount>
|
||||
<version>0.0.1</version>
|
||||
<version>1.0.0</version>
|
||||
<description>Kea DHCPv4 configuration</description>
|
||||
<items>
|
||||
<general>
|
||||
@ -15,6 +15,10 @@
|
||||
<Default>4000</Default>
|
||||
<Required>Y</Required>
|
||||
</valid_lifetime>
|
||||
<fwrules type="BooleanField">
|
||||
<Required>Y</Required>
|
||||
<Default>1</Default>
|
||||
</fwrules>
|
||||
</general>
|
||||
<ha>
|
||||
<enabled type="BooleanField">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user