Could not dump example.come zone: zone example.com/IN: NS 'ns1.example.com' has no address records (A or AAAA)

  • Version: i-MSCP >= 1.2.0
    Setup with two or more name servers


    Problem
    When updating i-MSCP to the latest version, the name server settings are not properly set when using slave name server provisioning on a hosted domain name.


    Let example.com be hosted on i-MSCP and ns1.example.com and ns2.example.com be the two name servers used (ns2 is a slave to ns1 and provided with updated information by a listener script). All Domains use the same ns entries (ns1.example.com and ns2.example.com) as glue records.


    When updating the DNS entries during i-MSCP setup, an error occurs:

    Code
    1. [ERROR] main::setupDbTasks: Servers::named::bind::_addDmnDb: Could not dump example.com zone: zone example.com/IN: NS 'ns1.example.com' has no address records (A or AAAA)
    2. zone ylabs.de/IN: NS 'ns2.example.com has no address records (A or AAAA)
    3. zone ylabs.de/IN: not loaded due to errors. at /usr/local/src/imscp-1.3.7/engine/PerlLib/iMSCP/DbTasksProcessor.pm line 446.
    4. autoinstaller::Functions::install: An error occurred while performing installation steps

    Workaround
    Backup zone file before update and insert it between creation of the zone file (while updating the domain) and inserting the NS entries from database.


    Fix

    To investigate

    Edited once, last by Starlight ().

  • When updating i-MSCP to the latest version, the nameserver settings are not properly set when using external name server on a hosted domain name.

    If you use an external DNS server, i-MSCP Bind server implementation shouldn't be involved at all. Please clarifiy a bit because I don't understand your setup. When you report a bug, make sure to provide us all steps allowing to reproduce it.


    Edit: You surely mean slave DNS server instead of external DNS server.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • See also: https://youtrack.i-mscp.net/issue/IP-1653


    Note: The behavior specified in #IP-1653 is the expected one. The user want to use the same NS for all its zones. The issue is due to the fact that i-MSCP is the master DNS server for the zone which is authoritative for those NS and that he forgot to add the A record.


    @Starlight


    First please, ensure that your're not in the same use case as above. If so, read my answer in the related issue.


    How do you have setup your slave DNS server exactly? Through the i-MSCP setup dialog (imscp-reconfigure -dar named)?
    I've just tried to add a slave DNS server through the setup dialog (imscp-reconfigure -dar named), and all worked as expected. Both, the NS and A records for the slave DNS server were added and no error has been raised.


    The slave IP that I've set for testing is 192.168.1.100 which point to a server for which the slave zone is not even created. Then, the i-MSCP bind9 server implementation has added the relevant A record as expected ns2 A 192.168.1.100 and the dump was successfull.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • The description in #IP-1653 fits. However, I set the A-records via the (own) DNS Function. It looks like, they get added later to the template.


    I see two solutions now:
    1) i-MSCP build the template completely, before it checks the DNS records or
    2) I write a listener which invokes the ns1 and ns2 A and AAAA records during installation


    For the second option, I would like to know, which i-MSCP event would be the best to catch?

  • 1) i-MSCP build the template completely, before it checks the DNS records or

    The problem is that custom DNS records are processed separately, and thus, the error is raised early ;) We will be able to process as you said once will we have the new task manager in place. Right now, processing order is managed trough the DB tasks processor which is limited.


    2) I write a listener which invokes the ns1 and ns2 A and AAAA records during installation

    This is the way to go. The event to listen on is either: beforeNamedAddDmnDb or afterNamedAddDmnDb


    See:

    In both case, you can check on the domain name throug: $data->{'DOMAIN_NAME'}


    See also:



    For the data passed-in.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • I created a listener file, and would add it to the i-mscp repository, when I patched the issue with the parallel A and AAAA records for the same NS (see @TODO).


    There must be also a possibility to get the location of the template file via variables in line 63 and 65. Help is highly appreciated.


  • @Starlight


    You complicate your live...


    There must be also a possibility to get the location of the template file via variables in line 63 and 65. Help is highly appreciated.

    This is not needed. What you're currently doing from line 60 to line 68 is totally useless. The content of the /etc/imscp/bind/parts/db.tpl template file is pre-loaded and passed-in to the listener as a scalar ref. You have just to modify the content of the variable by dereferencing it.


    Your listener will receives:

    • A ref to scalar containing the content of the /etc/imscp/bind/parts/db.tpl template file
    • A ref to hash containing data as provided by Module data provider method

    Now, if you want really override the template with your own (located elsewhere), you can always listen on the onLoadTemplate event. This event is triggered each time a template is loaded. For the case of the /etc/imscp/bind/parts/db.tpl template, the listeners receive:

    • The name of the server implementation (bind)
    • The template name (db.tpl)
    • A ref to a scalar in which you must write your own template content
    • A ref to a hash that contains data as provided by the module data provider methods

    See here: https://github.com/i-MSCP/imsc…ervers/named/bind.pm#L969


    The onLoadTemplate event is triggered before the beforeNamedAddDmnDb and afterNamedAddDmnDb events. Thus, if you listen on that event to override the default db.tpl template, your afterNamedAddDmnDb listener will receive your own template content.


    But again, in your use case, there is no need to override the default db.tpl template. You just need:


    • Check that the zone for which you act is the zone in which the NS are defined
    • Add the A DNS record (and AAAA record if ipv6 is enabled)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @Starlight


    Even in core, there is a bug regarding A and AAAA records.


    Code
    1. for (@nsIPs) {$dmnNsEntries .= process( { NS_NUMBER => $nsNumber }, $dmnNsEntry );$dmnNsAentries .= process({NS_NUMBER => $nsNumber,NS_IP_TYPE => $net->getAddrVersion( $_ ) eq 'ipv4' ? 'A' : 'AAAA',NS_IP => $_},$dmnNsAEntry);$nsNumber++;}


    NS names are badly generated due to the way the NS numbers are incremented.


    For now we get something like:


    Code
    1. ns1.example.com. IN A <IP_MASTER_DNS>ns2.example.com. IN AAAA <IP_MASTER_DNS>ns3.example.com. IN A <IP_SLAVE_DNS>ns4.example.com. IN AAAA <IP_SLAVE_DNS>

    while we should end with something like

    Code
    1. ns1.example.com. IN A <IP_MASTER_DNS>
    2. ns1.example.com. IN AAAA <IP_MASTER_DNS>
    3. ns2.example.com. IN A <IP_SLAVE_DNS>
    4. ns2.example.com. IN AAAA <IP_SLAVE_DNS>


    This can be easily fixed by processing IPv4 and IPV6 separately. But anyway, all this must be reviewed (dualstack support).

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • That might be true, if I just want to modify the content in a way like adding ns1 IN A IP. However, my plan was to use the build in functions of i-MSCP.


    The easiest way would be the definition of the DNS strings in an array and adding them in a one-liner.



    Your listener will receives:

    • A ref to scalar containing the content of the /etc/imscp/bind/parts/db.tpl template file
    • A ref to hash containing data as provided by Module data provider method

    That won't work, because the listener 10_named_override_default_ns_rr.pl already removed the block, before my listener kicks in... For getting the expected behavior, I would need to fix the other listener.


    Perl
    1. # Remove default nameservers records
    2. $$wrkFile =~ s/^(?:\@(?:\s+\d+)?\s+IN\s+NS|ns[0-9]\s+IN)\s+[^\n]+\n//gm;


    Comments?

  • That won't work, because the listener 10_named_override_default_ns_rr.pl already removed the block, before my listener kicks in... For getting the expected behavior, I would need to fix the other listener.


    Comments?

    Just change your listener load priority order. See https://github.com/i-MSCP/imsc…er-file-naming-convention


    Listeners are processed in FIFO order (first in, first out).

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206