Skip to content

Commit b8f4cac

Browse files
author
Marius Burkard
committed
Merge branch 'dns-dnssec' into 'stable-3.1'
DNSSEC-Implementation for BIND-Users (Including TLSA for DANE) This implements DNSSEC on a full automatic base. Whenever a zone gets added, changed or deleted it will be signed (or in case of deletion the keys get deleted) This adds full dnssec capabilities to the system. Hints: - DNSKEY-Records are not visible within ISPConfig as they get added by a script by the server cron. - If there is low available entropy (<400 bits) new keys will not generate. In this case the zonefile (which was never signed before) stays unsigned until next change of soa or any rr in that zone. IF a key exists zone files will always be signed. - I recommend installing haveged - especially on VMs - which raises available entropy by a huge amount of bits - only de and en language included. - DNSSEC can be switched on/off on a per zone base and is only available for primary zones (of course). - Zone-Transfers will transfer the signed zone if DNSSEC is enabled for the originating zone The scripts have been tested on my productive 3.0 server for about 4 weeks as well as a functional test for any scenarios I thought about in my 3.1 testing environment. More info (older version): https://www.howtoforge.com/community/threads/bit-hacky-implementation-of-dnssec-patch-and-tlsa-dane.71829/ ANOTHER HINT: Currently the New zone Wizard is not working. This also happens in latest ISPC master branch so I ignored that and filed a bug report: http://bugtracker.ispconfig.org/index.php?do=details&task_id=4069 //Edit: One more note: I left the wizard/templates unchanged as it is buggy at the moment. Providing a checkbox to switch dnssec_wanted between Y and N is up to you here. Should not be too complicated though... See merge request !269
2 parents ab0d78d + ecb8fc2 commit b8f4cac

32 files changed

+1334
-8
lines changed

TODO.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Installer
1313
--------------------------------------
1414

1515
- Add a function to let a server join a existing installation.
16+
- Add Package haveged to requirements (at least if entropy is low) as it raises available entropy significantly which is very needed for DNSSEC Key-generation
17+
If it is not installed and entropy is low generating dnssec-keys lasts minutes (and would time out the server thus is not done) and new signing keys are not generated.
18+
If there are no keys the zones can not be signed and will only be availableas a unsigned copy.
1619

1720
Uninstaller
1821
--------------------------------------
@@ -80,6 +83,7 @@ Remoting framework
8083
Interface
8184
--------------------------------------
8285
- Enhance the paging in lists (e.g. like this: [1 2 3 4 ... 10])
86+
- DNS: Add Checkbox to switch dnssec_wanted between Y and N to templates and/or wizard. I recommend doing it in the wizard though.
8387

8488
General tasks
8589
--------------------------------------

install/lib/installer_base.lib.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,27 @@ public function configure_powerdns() {
14691469

14701470

14711471
}
1472+
1473+
//** writes bind configuration files
1474+
public function process_bind_file($configfile, $target='/', $absolute=false) {
1475+
global $conf;
1476+
1477+
if ($absolute) $full_file_name = $target.$configfile;
1478+
else $full_file_name = $conf['ispconfig_install_dir'].$target.$configfile;
1479+
1480+
//* Backup exiting file
1481+
if(is_file($full_file_name)) {
1482+
copy($full_file_name, $config_dir.$configfile.'~');
1483+
}
1484+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master');
1485+
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
1486+
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
1487+
$content = str_replace('{mysql_server_ispconfig_database}', $conf['mysql']['database'], $content);
1488+
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
1489+
$content = str_replace('{ispconfig_install_dir}', $conf['ispconfig_install_dir'], $content);
1490+
$content = str_replace('{dnssec_conffile}', $conf['ispconfig_install_dir'].'/server/scripts/dnssec-config.sh', $content);
1491+
wf($full_file_name, $content);
1492+
}
14721493

14731494
public function configure_bind() {
14741495
global $conf;
@@ -1487,7 +1508,9 @@ public function configure_bind() {
14871508
chown($content, $conf['bind']['bind_user']);
14881509
chgrp($content, $conf['bind']['bind_group']);
14891510
chmod($content, 02770);
1490-
1511+
1512+
//* Install scripts for dnssec implementation
1513+
$this->process_bind_file('named.conf.options', '/etc/bind/', true); //TODO replace hardcoded path
14911514
}
14921515

14931516

install/sql/incremental/upd_dev_collection.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,13 @@ CREATE TABLE `ftp_traffic` (
203203

204204
ALTER TABLE `mail_forwarding` ADD COLUMN `allow_send_as` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `active`;
205205
UPDATE `mail_forwarding` SET `allow_send_as` = 'y' WHERE `type` = 'alias';
206+
207+
--- DNSSEC-Implementation by dark alex
208+
--- TODO: Review and resolve conflicts if more has been done in that column
209+
ALTER TABLE `dns_rr` CHANGE COLUMN `type` `type` ENUM('A','AAAA','ALIAS','CNAME','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','TXT','TLSA','DNSKEY') NULL DEFAULT NULL AFTER `name`;
210+
211+
ALTER TABLE `dns_soa`
212+
ADD COLUMN `dnssec_initialized` ENUM('Y','N') NOT NULL DEFAULT 'N',
213+
ADD COLUMN `dnssec_wanted` ENUM('Y','N') NOT NULL DEFAULT 'N',
214+
ADD COLUMN `dnssec_last_signed` BIGINT NOT NULL DEFAULT '0',
215+
ADD COLUMN `dnssec_info` TEXT NULL;

install/sql/ispconfig3.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ CREATE TABLE `dns_rr` (
478478
`server_id` int(11) NOT NULL default '1',
479479
`zone` int(11) unsigned NOT NULL DEFAULT '0',
480480
`name` varchar(255) NOT NULL DEFAULT '',
481-
`type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
481+
`type` enum('A','AAAA','ALIAS','CNAME','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','TXT','TLSA','DNSKEY') default NULL,
482482
`data` TEXT NOT NULL DEFAULT '',
483483
`aux` int(11) unsigned NOT NULL default '0',
484484
`ttl` int(11) unsigned NOT NULL default '3600',
@@ -539,6 +539,10 @@ CREATE TABLE `dns_soa` (
539539
`xfer` varchar(255) NOT NULL DEFAULT '',
540540
`also_notify` varchar(255) default NULL,
541541
`update_acl` varchar(255) default NULL,
542+
`dnssec_initialized` ENUM('Y','N') NOT NULL DEFAULT 'N',
543+
`dnssec_wanted` ENUM('Y','N') NOT NULL DEFAULT 'N',
544+
`dnssec_last_signed` BIGINT NOT NULL DEFAULT '0',
545+
`dnssec_info` TEXT NULL,
542546
PRIMARY KEY (`id`),
543547
UNIQUE KEY `origin` (`origin`),
544548
KEY `active` (`active`)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
options {
2+
directory "/var/cache/bind";
3+
4+
// If there is a firewall between you and nameservers you want
5+
// to talk to, you may need to fix the firewall to allow multiple
6+
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
7+
8+
// If your ISP provided one or more IP addresses for stable
9+
// nameservers, you probably want to use them as forwarders.
10+
// Uncomment the following block, and insert the addresses replacing
11+
// the all-0's placeholder.
12+
13+
// forwarders {
14+
// 0.0.0.0;
15+
// };
16+
17+
//========================================================================
18+
// If BIND logs error messages about the root key being expired,
19+
// you will need to update your keys. See https://www.isc.org/bind-keys
20+
//========================================================================
21+
dnssec-enable yes;
22+
dnssec-validation yes;
23+
dnssec-lookaside auto;
24+
25+
auth-nxdomain no; # conform to RFC1035
26+
listen-on-v6 { any; };
27+
};
28+

interface/web/dns/dns_ds_edit.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/dns_ds.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once '../../lib/config.inc.php';
42+
require_once '../../lib/app.inc.php';
43+
require_once './dns_edit_base.php';
44+
45+
// Loading classes
46+
class page_action extends dns_page_action {
47+
48+
}
49+
50+
$page = new page_action;
51+
$page->onLoad();
52+
53+
?>

interface/web/dns/dns_loc_edit.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/dns_loc.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once '../../lib/config.inc.php';
42+
require_once '../../lib/app.inc.php';
43+
require_once './dns_edit_base.php';
44+
45+
// Loading classes
46+
class page_action extends dns_page_action {
47+
48+
}
49+
50+
$page = new page_action;
51+
$page->onLoad();
52+
53+
?>
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/dns_tlsa.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once '../../lib/config.inc.php';
42+
require_once '../../lib/app.inc.php';
43+
44+
//* Check permissions for module
45+
$app->auth->check_module_permissions('dns');
46+
47+
// Loading classes
48+
$app->uses('tpl,tform,tform_actions,validate_dns');
49+
$app->load('tform_actions');
50+
51+
class page_action extends tform_actions {
52+
53+
function onShowNew() {
54+
global $app, $conf;
55+
56+
// we will check only users, not admins
57+
if($_SESSION["s"]["user"]["typ"] == 'user') {
58+
59+
// Get the limits of the client
60+
$client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
61+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
62+
63+
// Check if the user may add another mailbox.
64+
if($client["limit_dns_record"] >= 0) {
65+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
66+
if($tmp["number"] >= $client["limit_dns_record"]) {
67+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
68+
}
69+
}
70+
}
71+
72+
parent::onShowNew();
73+
}
74+
75+
function onSubmit() {
76+
global $app, $conf;
77+
78+
// Get the parent soa record of the domain
79+
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
80+
81+
// Check if Domain belongs to user
82+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
83+
84+
// Check the client limits, if user is not the admin
85+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
86+
// Get the limits of the client
87+
$client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
88+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
89+
90+
// Check if the user may add another mailbox.
91+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
92+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
93+
if($tmp["number"] >= $client["limit_dns_record"]) {
94+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
95+
}
96+
}
97+
} // end if user is not admin
98+
99+
100+
// Set the server ID of the rr record to the same server ID as the parent record.
101+
$this->dataRecord["server_id"] = $soa["server_id"];
102+
103+
// Update the serial number and timestamp of the RR record
104+
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id);
105+
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
106+
$this->dataRecord["stamp"] = date('Y-m-d H:i:s');
107+
108+
parent::onSubmit();
109+
}
110+
111+
function onInsert() {
112+
global $app, $conf;
113+
114+
// Check if record is existing already
115+
$duplicate_tlsa = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($this->dataRecord["zone"])." AND name = '".$app->db->quote($this->dataRecord["name"])."' AND type = '".$app->db->quote($this->dataRecord["type"])."' AND data = '".$app->db->quote($this->dataRecord["data"])."' AND ".$app->tform->getAuthSQL('r'));
116+
117+
if(is_array($duplicate_tlsa) && !empty($duplicate_tlsa)) $app->error($app->tform->wordbook["duplicate_tlsa_record_txt"]);
118+
119+
parent::onInsert();
120+
}
121+
122+
function onUpdate() {
123+
global $app, $conf;
124+
125+
// Check if record is existing already
126+
$duplicate_tlsa = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($this->dataRecord["zone"])." AND name = '".$app->db->quote($this->dataRecord["name"])."' AND type = '".$app->db->quote($this->dataRecord["type"])."' AND data = '".$app->db->quote($this->dataRecord["data"])."' AND id != ".$app->functions->intval($this->dataRecord["id"])." AND ".$app->tform->getAuthSQL('r'));
127+
128+
if(is_array($duplicate_tlsa) && !empty($duplicate_tlsa)) $app->error($app->tform->wordbook["duplicate_tlsa_record_txt"]);
129+
130+
parent::onUpdate();
131+
}
132+
133+
function onAfterInsert() {
134+
global $app, $conf;
135+
136+
//* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
137+
$soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
138+
$app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
139+
140+
//* Update the serial number of the SOA record
141+
$soa_id = $app->functions->intval($_POST["zone"]);
142+
$serial = $app->validate_dns->increase_serial($soa["serial"]);
143+
$app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
144+
}
145+
146+
function onAfterUpdate() {
147+
global $app, $conf;
148+
149+
//* Update the serial number of the SOA record
150+
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
151+
$soa_id = $app->functions->intval($_POST["zone"]);
152+
$serial = $app->validate_dns->increase_serial($soa["serial"]);
153+
$app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
154+
}
155+
156+
}
157+
158+
$page = new page_action;
159+
$page->onLoad();
160+
161+
?>

0 commit comments

Comments
 (0)