Solved CMD_API_DNS_ADMIN is broken? Can't open file /etc/bind/.db for reading

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
645
Location
The Earth
Hai guys, I use CMD_API_DNS_ADMIN to query list of domain but I always get the following error returned in json


Code:
{
    "error": "Error Reading db file",
    "result": "Can't open file /etc/bind/.db for reading\n"
}


This is the simple source code, you can test this via terminal (just change the variable server, username, password and for domain choose existing domain in your system):

Code:
#!/bin/bash
# Script name: test.sh

# If you want to test change change this login information:
server="http://server.bigdata.com:2222"
username="admin"
password="12321aa"
# change this domain to one of the domain in your DNS:
domain="test.com"

cmd_api="CMD_API_DNS_ADMIN"
data="domain=${domain}&json=yes"
method="POST"

# Call API
curl --silent --request "POST" --user "${username}":"${password}" --data "${data}" "${server}/${cmd_api}"


In debug mode this is the error part:

Code:
Named::readDB (): Can't open /etc/bind/.db for reading
Dynamic(api=1, error=1):
    text='Error Reading db file'
    result='Can't open file /etc/bind/.db for reading<br>

From my observation based on the error log above, directadmin did not read bind database from /etc/bind/domain.com.db but /etc/bind/.db (but I might be wrong but that is what it is telling from the error above). For example if you put domain=abc.com, it should read from /etc/bind/abc.com.db .
 
Last edited:
Sorry guys I found the issue, it was my mistake because the variable domain passed in data was misspelled as variable `domains` in my other test script. So domain passed was blanked. That was a silly mistake.
 
Last edited:
Back
Top