aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGoffredo Andreone <gandreone@pfsense.org>2007-02-22 16:02:47 +0000
committerGoffredo Andreone <gandreone@pfsense.org>2007-02-22 16:02:47 +0000
commit25423ed5b20bffeeca0b775be18c4b3cc459ec28 (patch)
tree7df2403bdd55515e98d5f4bdc934642ba83f848d /packages
parent2e73aec458a07a26c464687eb765f93eff87c092 (diff)
downloadpfsense-packages-25423ed5b20bffeeca0b775be18c4b3cc459ec28.tar.gz
pfsense-packages-25423ed5b20bffeeca0b775be18c4b3cc459ec28.tar.bz2
pfsense-packages-25423ed5b20bffeeca0b775be18c4b3cc459ec28.zip
Forwarding of DNS requests to tinyDNS server not functional in this version. Need to update to test download from web. Added files to forward DNS requests to tinyDNS server if SOA record is on tinyDNS otherwise forward to external Forwarding servers.
Diffstat (limited to 'packages')
-rw-r--r--packages/tinydns/tinydns.inc105
-rw-r--r--packages/tinydns/tinydns.xml14
2 files changed, 68 insertions, 51 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index 34ea45ec..39238e45 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -40,7 +40,7 @@ function tinydns_custom_php_install_command() {
log_error("Could not open /usr/local/etc/rc.d/svscan.sh for writing.");
return;
}
- $ip = $config['installedpackages']['tinydns']['config'][0]['ipaddress'];
+ $ipaddress = $config['installedpackages']['tinydns']['config'][0]['ipaddress'];
$minsegment = "10240";
$maxfilesize = "10240";
@@ -110,7 +110,6 @@ EOD;
fwrite($fd, $svscan);
fclose($fd);
conf_mount_ro();
- tinydns_custom_php_changeip_command();
filter_configure();
}
@@ -135,14 +134,12 @@ function tinydns_custom_php_deinstall_command() {
function tinydns_custom_php_changeip_command() {
global $g, $config;
conf_mount_rw();
- if($config['installedpackages']['tinydns']['config'][0]['bind2lan']){
- if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']){
- $ip = $config['interfaces']['lan']['ipaddr'];
- $ipmask = $config['interfaces']['lan']['subnet'];
- $arr = tinydns_get_ip_subnet_arpa($ip, $ipmask);
- $dnscacheip = $ip;
- $dnsuserip = $arr[0];
- }
+ if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']){
+ $ip = $config['interfaces']['lan']['ipaddr'];
+ $ipmask = $config['interfaces']['lan']['subnet'];
+ $arr = tinydns_get_ip_subnet_arpa($ip, $ipmask);
+ $dnscacheip = $ip;
+ $dnsuserip = $arr[0];
}
$dnsserverip = $config['installedpackages']['tinydns']['config'][0]['ipaddress'];
$updatecron = $config['installedpackages']['tinydns']['config'][0]['updatecron'];
@@ -158,22 +155,30 @@ function tinydns_custom_php_changeip_command() {
exec("echo {$dnsserverip} > /etc/tinydns/env/IP");
exec("/usr/bin/killall -9 tinydns");
- if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']){
- if(!is_dir("/service/dnscache")){
- exec("/usr/sbin/pw useradd Gdnscache");
- exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog /etc/dnscache {$dnscacheip}");
- exec("/bin/ln -s /etc/dnscache /service/");
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.original");
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.dnscache");
+ if($config['installedpackages']['tinydns']['config'][0]['enableforwarding'])
+ {
+ if(!is_dir("/service/dnscache")){
+ exec("/usr/sbin/pw useradd Gdnscache");
+ exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog /etc/dnscache {$dnscacheip}");
+ exec("/bin/ln -s /etc/dnscache /service/");
+ exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.original");
+ exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.dnscache");
+ }
+ exec("echo {$dnscacheip} > /etc/dnscache/env/IP");
+ exec("echo 1 > /etc/dnscache/env/FORWARDONLY");
+ tinydns_dnscache_forwarding_servers();
+ exec("touch /etc/dnscache/root/ip/{$dnsuserip}");
+ tinydns_create_soa_domain_list($dnsserverip);
+ exec("echo domain {$config['system']['domain']} > /var/etc/resolv.conf");
+ exec("echo nameserver {$dnscacheip} >> /var/etc/resolv.conf");
+ exec("/usr/bin/killall -9 dnscache");
+ }
+ else
+ {
+ exec("/bin/cp /var/etc/resolv.conf.original /var/etc/resolv.conf");
+ exec("echo > /etc/dnscache/env/IP");
+ exec("/usr/bin/killall -9 dnscache");
}
- exec("echo {$dnscacheip} > /etc/dnscache/env/IP");
- exec("echo 1 > /etc/dnscache/env/FORWARDONLY");
- tinydns_dnscache_forwarding_servers();
- exec("touch /etc/dnscache/root/ip/{$dnsuserip}");
- exec("echo domain {$config['system']['domain']} > /var/etc/resolv.conf");
- exec("echo nameserver {$dnscacheip} >> /var/etc/resolv.conf");
- exec("/usr/bin/killall -9 dnscache");
- }
conf_mount_ro();
filter_configure();
}
@@ -301,22 +306,10 @@ function tinydns_create_zone_file() {
}
/* Load the root servers if Forwarding is enabled */
+ /* Register LAN IP and SOA Forward and Reverse DNS recors in TinyDNS Server*/
if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
- if($config['system']['domain']) {
- $localdomain = $config['system']['domain'];
-// $localdomain = "";
-// $localhostmask = 8;
-// $localhostip = "127.0.0.1";
-// $localname = "localhost";
-// tinydns_complete_soa_record($fd, $localhostip, $localhostmask, $localname, $localdomain);
-// $forwardingservers = tinydns_register_forwarding_servers();
-// $forwardingservers .= tinydns_register_root_servers();
-// if($forwardingservers)fwrite($fd, $forwardingservers);
- }
- }
-
- /* Bind TinyDNS to LAN IP and register SOA for Forward and Reverse DNS */
- if($config['installedpackages']['tinydns']['config'][0]['bind2lan']) {
+ $forwardingservers = tinydns_register_root_servers();
+ if($forwardingservers)fwrite($fd, $forwardingservers);
if($config['system']['hostname']['domain']) {
$dhcpdhostname = $config['system']['hostname'];
if($config['dhcpd']['lan'])$dhcpddomain = $config['system']['domain'];
@@ -689,13 +682,43 @@ function tinydns_dnscache_forwarding_servers() {
fclose($fr);
$fr = fopen("/etc/dnscache/root/servers/@", "w");
if (! $fr) {
- printf("Error: cannot open resolv.conf in tinydns_dnscahe_forwarding_servers().\n");
+ printf("Error: cannot open resolv.conf in tinydns_dnscache_forwarding_servers().\n");
return 1;
}
if($iprecords)fwrite($fr, $iprecords);
fclose($fr);
}
+/* This rouine creates the files required by DNScache to send DNS requests to the Forwarders and TinyDNS Server*/
+function tinydns_create_soa_domain_list($dnsserverip){
+ if(file_exists("/service/tinydns/root/data"))
+ $tinydns_data = file_get_contents("/service/tinydns/root/data");
+ else
+ $tinydns_data = "";
+
+ $datalen = strlen($tinydns_data);
+ $startofrecord = 0;
+ while ($startofrecord < $datalen ){
+ $endofrecord = strpos($tinydns_data,"\n",$startofrecord);
+ $dnsrecord = substr($tinydns_data,$startofrecord,$endofrecord-$startofrecord);
+ $startofrecord = $endofrecord + 1;
+
+ $col1 = strpos($dnsrecord,":");
+ $fqdn = substr($dnsrecord,1,$col1-1);
+ if(!$fqdn)$fqdn = ".";
+ $rtypes = tinydns_get_dns_record_type($dnsrecord);
+ if($rtypes[0] == "SOA"){
+ $fr = fopen("/etc/dnscache/root/servers/{$fqdn}", "w");
+ if (! $fr) {
+ printf("Error: cannot open /etc/dnscache/root/servers/{$fqdn} in tinydns_create_soa_domain_list().\n");
+ return 1;
+ }
+ if($fqdn)fwrite($fr, $dnsserverip);
+ fclose($fr);
+ }
+ }
+}
+
/* This function will be replaced by an auto detect DNS cache servers routine */
/* At the moment ther is no tagging of DNSroute to a WAN port. It needs to be added */
function tinydns_register_forwarding_servers() {
diff --git a/packages/tinydns/tinydns.xml b/packages/tinydns/tinydns.xml
index 8fd4ebd9..91bd43da 100644
--- a/packages/tinydns/tinydns.xml
+++ b/packages/tinydns/tinydns.xml
@@ -3,9 +3,9 @@
<name>tinydns</name>
<version>1.0</version>
<configpath>installedpackages->package->tinydns</configpath>
- <title>TinyDNS: Settings</title>
+ <title>TinyDNS/DNScache: Settings</title>
<menu>
- <name>DNS Server</name>
+ <name>DNS Cache & Server</name>
<tooltiptext></tooltiptext>
<section>Services</section>
<url>/tinydns_status.php</url>
@@ -122,13 +122,7 @@
<field>
<fielddescr>Enable DNS Forwarders</fielddescr>
<fieldname>enableforwarding</fieldname>
- <description>Enable forwarding of unanswered DNS requests to the external DNS servers.</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Bind DNScache to LAN</fielddescr>
- <fieldname>bind2lan</fieldname>
- <description>Bind DNScache to the LAN IP and set up TinyDNS server with the LAN's SOA, NS, A, and PTR Records.</description>
+ <description>Enable DNScache forwarder on LAN IP and register LAN's SOA, NS, A, and PTR Records with TinyDNS Server.</description>
<type>checkbox</type>
</field>
<field>
@@ -146,7 +140,7 @@
<field>
<fieldname>ipaddress</fieldname>
<fielddescr>IP Address</fielddescr>
- <description>Bind TinyDNS to this IP address. Create a Virtual Carp IP on the LAN segment if Bind DNScache to LAN is set.</description>
+ <description>Bind TinyDNS to this IP address. Create a Virtual Carp IP on the LAN segment if Enable DNS Forwarders is set.</description>
<type>input</type>
</field>
<field>