PDA

View Full Version : How to setup DNS, Nameservers, Domain on Linux. (Got SERVFAIL reply)



Fli
06-23-2013, 04:54 PM
I refistered nameservers on my domain registar and set my VPS IP on it.

But ISPConfig control panel Domain setup did not made it working.

When i entered domain name to web browser it shows some DNS error message.

When loged via SSH to command line (CLI) i executed command:


dig mydomainname.com
(try also: dig +trace mydomainname.com)

I got SERVFAIL reply:

;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 13580


How i fixed that. I used this manual (http://kb.iweb.com/entries/21155058-Adding-new-domains-to-DNS-servers-from-the-shell) and i found it that usefull that im pasting it here in case it is lost:
-----------------------

To add a new domain, you need to edit two files related to Bind DNS server.

1. Adding an entry to Named.conf:

Login with SSH as root.
Open the file /etc/named.conf in any text editor.
At the end of the file, add the zone entry for domain.com in the following format:



zone "domain.com" {
type master;
file "/var/named/domain.com.db";
};

2. Creating the DB Record:


/var/named/domain.com.db is the path to the DB record file where you can add the Address records and MX records and all other DNS records related to domain.com.


Open the file /var/named/domain.com.db for editing in a text editor.
You can copy and paste the contents of the example below to the file (Edit each of the records according to what is needed for domain.com. Replace the IP address 10.10.10.10 with the domain.com IP address)
Save and exit the text editor.
Type this command to reload DNS server:


rndc reload

or try: service named restart

Example of /var/named/domain.com.db file:


; Zone file for domain.com
$TTL 14400
domain.com. 86400 IN SOA ns1.domain.com. host.domain.com. (
2012031401 ;Serial Number
86400 ;refresh
7200 ;retry
3600000 ;expire
86400 ;minimum
)

domain.com. 86400 IN NS ns1.domain.com.
domain.com. 86400 IN NS ns2.domain.com.


domain.com. 14400 IN A 10.10.10.10

localhost 14400 IN A 127.0.0.1

domain.com. 14400 IN MX 0 domain.com.

mail 14400 IN CNAME domain.com.
www 14400 IN CNAME domain.com.
ftp 14400 IN CNAME domain.com.
webmail 14400 IN A 10.10.10.10

For more information about how to manage the Bind DNS service, please consult the following links:

http://centos.org/docs/2/rhl-rg-en-7.2/s1-bind-configuration.html

http://www.cyberciti.biz/faq/tag/bind-9/

--------------------

SUMARY, In short, you need to do via command line:

1)
cp /etc/named.conf /etc/named.conf_backup; vim /etc/named.conf
add content of the first box there

2)
vim /var/named/YOURDOMAIN.com.db
if the file is empty, add content of second box (above) if there is some data, backup the fiel first and try to modiffy or create new file with code in above box. Dont forget to replace IP and your domain name as described above.