Current time: 04-26-2024, 07:31 AM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] powerdns and isp-control
Author Message
uwe Offline
Junior Member
*

Posts: 68
Joined: Feb 2008
Reputation: 0
Post: #1
[HowTo] powerdns and isp-control
Hello,

I've been trying to get ispcp and powerdns to work togather, here is what i do to get it, its not really generic and im using it in testing environment.

Install pdns-server and pdns-backend-mysql (im using debian)

create tables domains, records and supermasters in ispcp database following this doc http://doc.powerdns.com/generic-mypgsql-backends.html

configure pdns to use mysql-backend and set the username and password and database name ..etc, i also used bind backend to serve old domains i didnt have imported into pdns database, this can be also achieved by using bind2mysql script but i chose not to since im using domain ID from ispcp and not relaying on pdns to set the domain ID.

then i modify ispcp-dmn-mngr (/var/www/ispcp/engine)

in sub dmn_add_named_cfg_data
around the store_file function and before the return add:
PHP Code:
doSQL("INSERT INTO domains values (@$dmn_data[0],'$dmn_name',NULL,NULL,'MASTER',NULL,NULL)"); 

in sub dmn_del_named_cfg_data , around where we save a working copy
PHP Code:
doSQL("DELETE FROM domains where id = @$dmn_data[0]"); 
in sub dmn_add_named_db_data, around where we store generated data,(store_file) before the returns
PHP Code:
    doSQL("INSERT INTO records values (NULL,@$dmn_data[0],'$dmn_name','SOA','ns1.$dmn_name. postmaster.$dmn_name$time2 4800 3600 432000 21600',21600,0,1206429418)");
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','', 'NS','ns1.$dmn_name',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','', 'NS','ns2.$dmn_name',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','', 'MX','mail.$dmn_name',21600,10,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','"$dmn_name "', 'A','" $dmn_ip "',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','www', 'A','" $dmn_ip "',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$dmn_data[0]','$dmn_name.', 'TXT','\"v=spf1 a mx ip4:$dmn_ip ~all\"',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'localhost', 'A','127.0.0.1',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'mail', 'A','$base_svr_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'ns1', 'A','$base_svr_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'ns2', 'A','$sec_dns_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'imap', 'CNAME','mail',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'pop', 'CNAME','mail',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'pop3', 'CNAME','mail',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'smtp', 'CNAME','mail',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL',@$dmn_data[0],'ftp', 'CNAME','www',21600,0,1206426697 )") ; 

and in dmn_del_named_db_data, before the returns, near del_file do:

PHP Code:
doSQL("DELETE FROM records where domain_id = @$dmn_data[0]"); 

and now we modify dmn-sub-mngr, here we modify two functions:

sub sub_add_named_cfg_data, near the store_file call, and before the return:

PHP Code:
doSQL("INSERT INTO records values ('NULL','@$sub_data[5]','$sub_pref', 'A','$dmn_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$sub_data[5]','www.$sub_pref', 'A','$dmn_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$sub_data[5]','ftp.$sub_pref', 'A','$dmn_ip',21600,0,1206426697 )") ;
    
doSQL("INSERT INTO records values ('NULL','@$sub_data[5]','localhost.$sub_pref', 'A','127.0.0.1',21600,0,1206426697 )") ; 
and sub sub_del_named_cfg_data, near storing prepared data (also store_file call) and before return:
PHP Code:
doSQL("DELETE FROM records where domain_id='@$sub_data[5]' AND name='$sub_pref' AND type='A'") ;
    
doSQL("DELETE FROM records where domain_id='@$sub_data[5]' AND name='www.$sub_pref' AND type='A'") ;
    
doSQL("DELETE FROM records where domain_id='@$sub_data[5]' AND name='ftp.$sub_pref' AND type='A'") ;
    
doSQL("DELETE FROM records where domain_id='@$sub_data[5]' AND name='localhost.$sub_pref' AND type='A'") ; 
(This post was last modified: 11-25-2008 03:09 AM by BeNe.)
07-24-2008 08:46 PM
Find all posts by this user Quote this message in a reply
BioALIEN Offline
Public Relations Officer
*****
Dev Team

Posts: 620
Joined: Feb 2007
Reputation: 5
Post: #2
RE: powerdns and isp-control
Thank you for this HowTo. If there's a way, we can perhaps include this to the core code as we lack a DNS management tool.
07-30-2008 01:03 AM
Find all posts by this user Quote this message in a reply
uwe Offline
Junior Member
*

Posts: 68
Joined: Feb 2008
Reputation: 0
Post: #3
RE: powerdns and isp-control
well, that would be great, but i couldn't find any guidelines on what the plans are except that pdns will be supported in 1.1, or some domain management system will be incorporated in 1.1 ... so this approach mimics the templates used for bind and ties them into the code, which is not such a great idea, but i wanted pdns and thats how i got it to work.

i'd love to try to help in getting a DNS management tool into pdns, and i actually do have a somewhat working version on pdnsadmin but im doing it blindly, i.e. there is no guidelines how the development team actually wants to have it.
07-31-2008 08:28 AM
Find all posts by this user Quote this message in a reply
CHBIE Offline
Junior Member
*

Posts: 225
Joined: May 2008
Reputation: 11
Post: #4
RE: [HowTo] powerdns and isp-control
Hallo

wäre es möglich, dass jemand die angepasste ispcp-dmn-mngr posten könnte?

is it possible that somebody could post the adapted ispcp-dmn-mngr?

Gruss CHBIE
(This post was last modified: 02-07-2009 06:52 PM by CHBIE.)
02-07-2009 06:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
mafia Offline
Banned

Posts: 170
Joined: May 2008
Post: #5
RE: [HowTo] powerdns and isp-control
hello,

you speak the line

#
# Let's save working copy;
#
$rs = store_file($working_cfg, $working, $main::cfg{'ROOT_USER'}, $main$
return $rs if ($rs != 0);

j is the line that adds

doSQL ( "INSERT INTO domains values (@$dmn_data[0],'$dmn_name',NULL,NULL,'MASTER',NULL,NULL)" );
02-08-2009 07:22 AM
Find all posts by this user Quote this message in a reply
Uwe Driessen Offline
Junior Member
*

Posts: 21
Joined: Feb 2009
Reputation: 0
Post: #6
RE: [HowTo] powerdns and isp-control
its a great howto
i have found that the code has little mistake
perhaps in pdns domains the id field is uniq and auto_increment
it join to the record.domain_id.
so if you have domainaliasses the '@$dmn_data[0]' from ISPCP is not the same in domains.id and record.domain_id.
If you want to update or delete the record you must select the right value.
here is my diff for ISPCP 1.0 Stable

take a look at the last post.

(07-30-2008 01:03 AM)BioALIEN Wrote:  Thank you for this HowTo. If there's a way, we can perhaps include this to the core code as we lack a DNS management tool.

i think if you make an interface for the DNS its easy to wrote this as a module that you can bind in ISPCP.

in ispcp.conf a value like "BIND" or "PDNS" that call a file that named so and the values from ispcp you give them like

update, name,ip...
or
delete, name, ip....
or
insert, name, ip....

so the module can wrote with minimal code only controlled by the variables.


Attached File(s)
.zip  pdns_neu.zip (Size: 2.29 KB / Downloads: 26)
(This post was last modified: 10-01-2009 04:33 PM by Uwe Driessen.)
03-26-2009 11:41 AM
Find all posts by this user Quote this message in a reply
uwe Offline
Junior Member
*

Posts: 68
Joined: Feb 2008
Reputation: 0
Post: #7
RE: [HowTo] powerdns and isp-control
Maybe we should use zone2sql from pdns to convert chunks of zones to sql statements, that would be DB for future use with other db backends! the only drawback i can think of that we need to use a patched version that respects the --start-id when used in conjunction with --zone ... this ofcourse does not do the required tests Uwe Driessen suggested, but would make changes done to BIND zones templates apply to PDNS.
04-01-2009 07:13 PM
Find all posts by this user Quote this message in a reply
uwe Offline
Junior Member
*

Posts: 68
Joined: Feb 2008
Reputation: 0
Post: #8
RE: [HowTo] powerdns and isp-control
(04-01-2009 07:13 PM)uwe Wrote:  Maybe we should use zone2sql from pdns to convert chunks of zones to sql statements, that would be DB for future use with other db backends! the only drawback i can think of that we need to use a patched version that respects the --start-id when used in conjunction with --zone ... this ofcourse does not do the required tests Uwe Driessen suggested, but would make changes done to BIND zones templates apply to PDNS.

I take that back, it would be better to generate bind zone from the database !
04-01-2009 08:16 PM
Find all posts by this user Quote this message in a reply
Uwe Driessen Offline
Junior Member
*

Posts: 21
Joined: Feb 2009
Reputation: 0
Post: #9
RE: [HowTo] powerdns and isp-control
(04-01-2009 07:13 PM)uwe Wrote:  Maybe we should use zone2sql from pdns to convert chunks of zones to sql statements, that would be DB for future use with other db backends! the only drawback i can think of that we need to use a patched version that respects the --start-id when used in conjunction with --zone ... this ofcourse does not do the required tests Uwe Driessen suggested, but would make changes done to BIND zones templates apply to PDNS.

that was to easy *gg yes i know that PDNS kann read from Bind files but i have not only to store the DNS from one Maschine the DNS hold data from a lot of Domains that are not hostet by ISPCP so i brought the database for this work
(This post was last modified: 04-03-2009 03:54 AM by Uwe Driessen.)
04-01-2009 08:21 PM
Find all posts by this user Quote this message in a reply
uwe Offline
Junior Member
*

Posts: 68
Joined: Feb 2008
Reputation: 0
Post: #10
RE: [HowTo] powerdns and isp-control
Quote:for store in pdns.records (not all the statements but you see how i do it)
only the first 2 statements works an i not know why

Code:
my ($myrdatsoa,$myrdatns1, $myrdatns2, $myrdatmx1, $myrdata1, $myrdata2)  = (undef, undef, undef, undef, undef, undef);
        ($rs, $myrdatsoa) = doSQL("SELECT IF(
                                        (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND TYPE = 'SOA')>0,
                                        (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND TYPE = 'SOA'),
                                        'NULL')"
                               );
#        return $rs if ($rs != 0);
        doSQL("INSERT INTO pdns.records(id, domain_id, name, type, content, ttl, prio, change_date)
               SELECT '$myrdatsoa', t1.id,  '$dmn_name', 'SOA', concat( 'ns1.deltaweb.de. hostmaster.deltaweb.de.',
                        CURDATE( ) +0, '00 86400 7200 604800 1800' ) , 21600, 0, Unix_timestamp( )
               FROM pdns.domains t1 where t1.name = '$dmn_name'
               ON DUPLICATE KEY UPDATE name =  '$dmn_name', domain_id = t1.id, type = 'SOA',
                        content = concat('ns1.deltaweb.de. hostmaster.deltaweb.de.',CURDATE() + 0,'00 86400 7200 604800 1800'),
                        ttl= 21600,
                        prio=0,
                        change_date = Unix_timestamp()"
             );
        ($rs, $myrdatns1) = doSQL("SELECT IF(
                                (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND t2.type = 'NS' AND t2.content = 'ns1.deltaweb.de')>0,
                                (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND t2.type = 'NS' AND t2.content = 'ns1.deltaweb.de'),
                                 'NULL')"
                               );
#        return $rs if ($rs != 0);
        doSQL("INSERT INTO pdns.records(id, domain_id, name, type, content, ttl, prio, change_date)
               SELECT '$myrdatns1', t1.id,  '$dmn_name', 'NS', 'ns1.deltaweb.de', ) , 21600, 0, Unix_timestamp( )
               FROM pdns.domains t1 where t1.name = '$dmn_name'
               ON DUPLICATE KEY UPDATE name =  '$dmn_name', domain_id = t1.id, type = 'NS',
                        content = 'ns1.deltaweb.de',
                        ttl= 21600,
                        prio=0,
                        change_date = Unix_timestamp()"
             );

        ($rs, $myrdatns2) = doSQL("SELECT IF(
                                 (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND t2.type = 'NS' AND t2.content = 'ns2.deltaweb.de')>0,
                                 (SELECT t2.id FROM pdns.records t2 WHERE t2.name = '$dmn_name' AND t2.type = 'NS' AND t2.content = 'ns2.deltaweb.de'),
                                 'NULL')"
                               );
#         return $rs if ($rs != 0);

I'm not sure whic statements you mean, but i think the thing is that you shouldnt inderst id for the records, since they are autoincrement .
04-02-2009 12:38 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


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