Check secondary nameserver when adding domain

jouwnaam

Verified User
Joined
Mar 17, 2005
Messages
39
We use our secondary nameserver for multiple DirectAdmin servers. Most of the time this goes without problems.

Problems do occur however when domain.com is already added at DirectAdmin server A and somebody also adds domain.com at DirectAdmin server B. This should not be allowed as the secondary nameserver can't serve the same domain twice.

Is there anything we can do to prevent adding a domain that is already served on the secondary (non DirectAdmin) nameserver?
 
>> Multi Server Setup
Make sure domain check is ticked.

Domain Check: DA will first check the specified server before creating a domain to ensure the domain does not exist.
 
So are there 3 servers in this scenario?
DA (a) DA (b) plus another name server.

If this is the case you could still tick domain check on both of the DA servers I think? If not you could get a DA VPS the VPS lic is only $5 /month or get an owned lic for $89/month.

Or if you already have two DA servers there is really no need for a third server; since each DA server can backup each others DNS.
 
We do have multiple DA servers, but they do not backup eachothers DNS. All DA servers use 1 external nameserver.

To keep things simple, let's say there is only 1 DA server. The other server is the secondary nameserver without DA. We don't want to run DA on it since that's a complete overkill (no need for mail/mysql/apache/control panel etc.) and a potential extra security risk. It's just a slave nameserver and not a full-blown webserver.

How can we check if the to-be-added domain is already served by the slave nameserver? If it is, DA should not allow that domain to be added.
 
I just found this:
http://help.directadmin.com/item.php?id=203

We could use this to check if the domain is served by our backup nameserver. If it is, we reject the domain with an error.

Next step: how to create such a script. :)

[edit]

Problem solved! Use this as /usr/local/directadmin/scripts/custom/domain_create_pre.sh (change your.backup.nameserver.com to the real backup nameserver)

Code:
#!/usr/local/bin/php
<?php
$domain = getenv("domain");

function checkDomain($domain)
{
        $result = `nslookup $domain your.backup.nameserver.com`;
        $result = strtolower($result);
        if(eregi("can't find $domain",$result))
        {
                return FALSE;
        }
        return TRUE;
}

if( checkDomain($domain) )
{
        echo 'Domain already active.';
        exit(1);
}
else
{
        exit(0);
}
?>

[/edit]
 
Last edited:
Why did you write it in php it would of been alot easier in sh.
 
Why did you write it in php it would of been alot easier in sh.

Easier depends on point of view. Like me for example I know a lot of perl, some php, but almost nothing of sh. I never needed sh for anything extensive. I have always been able to accomplish what I needed using perl. So for me any server administration is going to be easier for me to do in perl than anything else.
 
Master2Slave DNS Replicator (search these forums) may do what you want; it automatically checks for dupes and notifies a specified email address. It does not require DirectAdmin be running, but uses standard BIND technology.

Jeff
 
Back
Top