Posts by jonci

    Sorry for my outdate solution.


    I didn't find your post when I searched for "auto secondary dns server".
    I only found the ispcp solution and I tried to modify that.


    Your solution is better, thank you!

    Original: http://noe.wikidot.com/automat…ndary-dns-for-ispcp-howto
    It was revised for i-MSCP.


    [size=x-large]1. on i-MSCP server (primary DNS)[/size]


    [size=large]1.1. domain list query[/size]


    Create the /var/www/imscp/gui/public/domainlist.php file with the following content:

    PHP
    1. <?phprequire 'imscp-lib.php';$cfg = iMSCP_Registry::get('config');$db = iMSCP_Registry::get('db');$count_query = " SELECT COUNT(`domain_id`) AS cnt FROM `domain`";$query = " SELECT `domain_name` FROM `domain` ORDER BY `domain_id` ASC";$rs = execute_query($db, $count_query);$records_count = $rs->fields['cnt'];$rs = execute_query($sql, $query); if ($rs->rowCount() == 0) { echo "//NO DOMAINS LISTED"; } else { echo "//$records_count HOSTED DOMAINS LISTED ON $cfg->SERVER_HOSTNAME [$cfg->BASE_SERVER_IP]\n"; echo "//CONFIGURATION FOR MAIN DOMAIN\n"; echo "zone \"$cfg->BASE_SERVER_VHOST\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/$cfg->BASE_SERVER_VHOST.db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; while (!$rs->EOF){ echo "zone \"".$rs->fields['domain_name']."\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/".$rs->fields['domain_name'].".db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; $rs->moveNext(); } }echo "//END DOMAINS LIST\n";?>


    Change the owner of the file:

    Code
    1. chown vu2000:vu2000 -R /var/www/imscp/gui/public/domainlist.php


    To protect the domainlist.php create the /var/www/imscp/gui/public/.htaccess file with following content:

    Code
    1. <Files domainlist.php> Order Deny,Allow Deny from all Allow from <SECONDARY_DNS_IP_ADDRESS></Files>


    After that only the secondary DNS server can reach the file.


    [size=large]1.2. BIND9 setup[/size]


    Go to the directory of bind9 in order to create the communication key between the two bind9:

    Code
    1. cd /etc/binddnssec-keygen -a hmac-md5 -b 128 -n HOST TRANSFER


    To speed up the generation type something on the keyboard!


    After the key was created to view the key in base64 encoding form type the following command:

    Code
    1. cat Ktransfer.*.key | rev | cut -d' ' -f1 | rev


    It will be neccessary later!


    Append the following content to the /etc/bind/named.conf.options file (after the options {} content)

    Code
    1. ////SECONDARY NS//key "TRANSFER" { algorithm hmac-md5; secret "<base64-encrypted-key>";};server <SECONDARY_DNS_IP_ADDRESS> { keys { TRANSFER; };};


    After that restart the BIND9:

    Code
    1. service bind9 restart


    [size=x-large]2. On the secondary DNS server[/size]


    [size=large]2.1. BIND9 setup[/size]


    Append the following content to the /etc/bind/named.conf.local file:

    Code
    1. include "/etc/bind/named.conf.backup";


    Append the following content to the /etc/bind/named.conf.options file (after the options {} content)

    Code
    1. ////SECONDARY NS//key "TRANSFER" { algorithm hmac-md5; secret "<base64 encrypted key>";};server <IMSCP_SZERVER_IP_ADDRESS> { keys { TRANSFER; };};


    After that restart the BIND9:

    Code
    1. service bind9 restart


    Let's test to get the domain list from the primary server:

    Code
    1. /usr/bin/wget --no-check-certificate https://<IMSCP-URL>/domainlist.php -O -


    If we can see the DNS-zone definitions everything works well and we can set the automatic update by cron.
    Create the /etc/cron.d/imscp_dns_update file with the following content:

    Code
    1. */5 * * * * root /usr/bin/wget --no-check-certificate https://<IMSCP-URL>/domainlist.php -O /etc/bind/named.conf.backup && /etc/init.d/bind9 reload && /usr/bin/logger "i-MSCP: Backup zones updated\!"


    So the DNS-zone definitions are automatically updated every 5 minutes from the primary server. If we do everything properly, we can see the <domain>.db files in the /var/cache/bind/ directory.


    Finally hurray! :)

    Eredeti: http://noe.wikidot.com/automat…ndary-dns-for-ispcp-howto
    Átírtam, hogy i-MSCP-vel működjön.


    [size=x-large]1. i-MSCP szerveren[/size]


    [size=large]1.1. domain list előállítása[/size]


    Hozzuk létre a /var/www/imscp/gui/public/domainlist.php fájlt az alábbi tartalommal:

    PHP
    1. <?phprequire 'imscp-lib.php';$cfg = iMSCP_Registry::get('config');$db = iMSCP_Registry::get('db');$count_query = " SELECT COUNT(`domain_id`) AS cnt FROM `domain`";$query = " SELECT `domain_name` FROM `domain` ORDER BY `domain_id` ASC";$rs = execute_query($db, $count_query);$records_count = $rs->fields['cnt'];$rs = execute_query($sql, $query); if ($rs->rowCount() == 0) { echo "//NO DOMAINS LISTED"; } else { echo "//$records_count HOSTED DOMAINS LISTED ON $cfg->SERVER_HOSTNAME [$cfg->BASE_SERVER_IP]\n"; echo "//CONFIGURATION FOR MAIN DOMAIN\n"; echo "zone \"$cfg->BASE_SERVER_VHOST\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/$cfg->BASE_SERVER_VHOST.db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; while (!$rs->EOF){ echo "zone \"".$rs->fields['domain_name']."\"{\n"; echo "\ttype slave;\n"; echo "\tfile \"/var/cache/bind/".$rs->fields['domain_name'].".db\";\n"; echo "\tmasters { $cfg->BASE_SERVER_IP; };\n"; echo "\tallow-notify { $cfg->BASE_SERVER_IP; };\n"; echo "};\n"; $rs->moveNext(); } }echo "//END DOMAINS LIST\n";?>


    Állítsuk be a tulajdonosát:

    Code
    1. chown vu2000:vu2000 -R /var/www/imscp/gui/public/domainlist.php


    Védjük meg a fájlt a külvilágtól, hogy csak a másodlagos DNS szerver használhassa, ehhez hozzuk létre a /var/www/imscp/gui/public/.htaccess fájlt az alábbi tartalommal:

    Code
    1. <Files domainlist.php> Order Deny,Allow Deny from all Allow from SECONDARY_DNS_IP_CIME</Files>


    [size=large]1.2. BIND9 módosítása[/size]


    Lépjünk be a bind9 config könyvtárába és hozzunk létre egy kulcsot a bind9 közötti kommunikációjához:

    Code
    1. cd /etc/binddnssec-keygen -a hmac-md5 -b 128 -n HOST TRANSFER


    Felgyorsíthatjuk a generálást, ha elkezdünk gépelni össze-vissza a parancs kiadása után.


    Ha elkészült a kulcs, adjuk ki az alábbi parancsot, hogy láthassuk a base64 kódolt kulcsot:

    Code
    1. cat Ktransfer.*.key | rev | cut -d' ' -f1 | rev


    Szükségünk lesz a következő lépésnél.


    Adjuk hozzá az alábbit a /etc/bind/named.conf.options fájl végéhez (options {} rész után)

    Code
    1. ////SECONDARY NS//key "TRANSFER" { algorithm hmac-md5; secret "<base64 kódolt kulcs>";};server SECONDARY_DNS_IP_CIME { keys { TRANSFER; };};


    Majd indítsuk újra a BIND9-et:

    Code
    1. service bind9 restart


    [size=x-large]2. Másodlagos DNS szerveren[/size]


    [size=large]2.1. BIND9 módosítása[/size]


    Adjuk hozzá a /etc/bind/named.conf.local fájl végéhez az alábbit:

    Code
    1. include "/etc/bind/named.conf.backup";


    Majd adjuk hozzá az alábbit a /etc/bind/named.conf.options fájl végéhez (options {} rész után)

    Code
    1. ////SECONDARY NS//key "TRANSFER" { algorithm hmac-md5; secret "<base64 kódolt kulcs>";};server IMSCP_SZERVER_IP_CIME { keys { TRANSFER; };};


    Majd indítsuk újra a BIND9-et:

    Code
    1. service bind9 restart


    Teszteljük, hogy le tudjuk-e kérdezni a domain listát:

    Code
    1. /usr/bin/wget --no-check-certificate https://IMSCP-URL/domainlist.php -O -


    Ha megjelennek a DNS-zóna definíciók, akkor minden remekül működik és ideje beállítani, hogy automatikusan frissüljön a domain-ek listája. Ehhez hozzuk létre a /etc/cron.d/imscp_dns_update fájtl az alábbi tartalommal:

    Code
    1. */5 * * * * root /usr/bin/wget --no-check-certificate https://IMSCP-URL/domainlist.php -O /etc/bind/named.conf.backup && /etc/init.d/bind9 reload && /usr/bin/logger "i-MSCP: Backup zones updated\!"


    A létrehozása után 5 percenként frissülnek a DNS-zónák az éles szerverről. Ha mindent jól csináltunk, akkor a /var/cache/bind/ könyvtárban megjelennek a <domain>.db fájlok.


    Lehet örülni :)


    Thank you for taking care of this issue!


    I have already solved it with updating the mysql.user table with right value.

    When you choose the remote option for the SQL server, you are asked for the IP address of the remote SQL server and you are also asked for the hostname to use for SQL users created by i-MSCP.


    What is the value of the parameter DATABASE_USER_HOST in your /etc/imscp1/imscp.conf file?


    $ grep 'DATABASE.*HOST' /etc/imscp/imscp.conf
    DATABASE_HOST = 10.0.0.10
    DATABASE_USER_HOST = 10.0.0.10

    for example:
    eth0's IP is 192.168.0.1 (external interface) -> set for i-MSCP IP address
    eth1's IP is 10.0.0.1 (local lan interface)
    remote sql server's IP is 10.0.0.10


    i-MSCP version: 1.1.0-rc3


    If "remote server" is being choosen at "SQL service" page, and I set 10.0.0.10 as SQL server address during the installation process, wrong value appeares in the host cell of the "dovecot_user" in mysql.user table. The eth1 IP address should appeare in the host cell instead of eth0, as at the other user's happen (vftp, roundcube_mail, pma).