Current time: 05-07-2024, 03:51 AM Hello There, Guest! (LoginRegister)


Post Reply 
how to setup nameservers
Author Message
ephigenie Offline
Project Leader
*******
Administrators

Posts: 1,578
Joined: Oct 2006
Reputation: 15
Post: #3
RE: how to setup nameservers
you need a 2nd server and then :

you create a folder below your admin domain i.e. ( admin.yourdomain.com/tools/dns-export.php )
then you create a script which exports a named.conf.local so your slave dns server knows about the domains it needs to get....

Code:
<?
$link = mysql_connect("localhost", "pdns_sql", "your db pw")
    or die("No connection possible: " . mysql_error());
mysql_select_db("ispcp") or die("Database selection impossible!");

/* execute SQL query for domains */
$query = "SELECT domain_name as name FROM domain union select alias_name as name from domain_aliasses ";
$query = "union select (select concat(a.subdomain_name,'.',b.domain_name) from subdomain a left join domain as b on a.domain_id=b.domain_id) as name";$query = "union select (select concat(a.subdomain_alias_name,'.',b.alias_name) from subdomain_alias a left join domain_aliasses b on a.alias_id=b.alias_id) as name ";
$result = mysql_query($query) or die("Queery failed: " . mysql_error());


$zonefile = "# autogenerated Zonefile do not edit !\r\n";
$zonefile .= "include \"/etc/bind/zones.rfc1918\";\r\n";

$master = "<IP of your dns master>";
$zonefiledir = "/var/cache/bind";

while ($daten = mysql_fetch_array($result)) {
$zone = $daten['name'];
if ( $zone !="NULL" ) { 
        $zonefile .= "zone \"$zone\" {   \n
                type slave; \n
                file \"$zonefiledir/$zone.db\"; \n
                masters { $master; }; \n
                allow-notify { $master; }; \n
                }; \n
        
                ";
        }
}

echo $zonefile;

?>

then you place a script on the slave dns server like that :
Code:
#!/bin/sh
#
# update bind zones every 20 minutes
#
PATH=/usr/bin:/bin:/usr/sbin
LOG=/var/log/dns-update.log

date > $LOG
wget -O /etc/bind/named.conf.local http://admin.yourdomain.com/tools/dns_export.php >> $LOG 2>&1
if [ $? = 0 -a -s /etc/bind/named.conf.local ]; then
        rndc reload >> $LOG 2>&1
else
        echo "Uh, oh...." >> $LOG
fi

Then check that the slave server gets a valid named.conf.local file.
If yes, take care to make a section like

Code:
<location /tools/dns_export.php>
     order deny, allow
     deny from all
     allow from <ip of your slave server>
</location>

so that not everybody can read your domain infos ...
That should do the trick basically ..
(This post was last modified: 03-06-2012 11:36 PM by ephigenie.)
03-06-2012 11:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
how to setup nameservers - zx-75 - 10-08-2011, 08:57 PM
RE: how to setup nameservers - Boss Online - 02-29-2012, 06:34 AM
RE: how to setup nameservers - ephigenie - 03-06-2012 11:36 PM
RE: how to setup nameservers - Boss Online - 03-15-2012, 07:48 AM
RE: how to setup nameservers - ephigenie - 03-15-2012, 08:19 PM
RE: how to setup nameservers - RouterRat - 05-23-2012, 01:15 PM
RE: how to setup nameservers - ephigenie - 05-25-2012, 04:13 PM
RE: how to setup nameservers - RouterRat - 05-26-2012, 04:42 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)