DNS Service Failure: Syntax error and Duplicate Zone Definitions

The DNS service was down and while starting the service we were getting the below error.


Nov 05 21:53:00 host.xyzserver.net bash[137415]: /etc/named.conf:7757: '}' expected near end of file

Nov 05 17:28:08 host.xyzserver.net bash[2759376]: /etc/named.conf:7799: unexpected token near end of file

/etc/named.conf:3920: zone 'xyzdomain.net': already exists previous definition: /etc/named.conf:84

Solution:-

1. Open the /etc/named.conf File
First, open the /etc/named.conf file in a text editor of your choice. You can use vi, nano, or any other text editor you are comfortable with.

2. Check for Missing Braces
Look for any missing closing braces (}). Ensure that every opening brace { has a corresponding closing brace. In particular in my case, I checked around line 7757 and near the end of the file where the error message indicated a possible issue.

 

3. Validate Configuration Syntax
Once you've corrected any syntax issues, validate the configuration using the named-checkconf command. This will help you identify any remaining syntax errors in the configuration file, in our case we get Duplicate Zone Definitions error.

~~~
named-checkconf /etc/named.conf

~~~

 

4. Address Duplicate Zone Definitions
After correcting syntax errors, we encountered new errors related to duplicate zone definitions. For example, you might see an error like this:

~~~

[root@host named]# named-checkconf /etc/named.conf
/etc/named.conf:3920: zone 'xyzdomain.net': already exists previous definition: /etc/named.conf:84
/etc/named.conf:3925: zone 'abcdomain.net': already exists previous definition: /etc/named.conf:89

~~~
This indicates that the same zone has been defined multiple times in the /etc/named.conf file.

 

5. Remove or Comment Out Duplicate Zone Entries
Open the /etc/named.conf file again in a vi text editor and navigate to the lines mentioned in the error (e.g., lines 84, 89, etc.). You will need to locate the duplicate zone entries.

Once found, you can either remove or comment out the duplicate zone definitions. To comment out a section, add // at the beginning of each line in the duplicate zone definition block. For example:

~~~
// zone "xyzdomain.net" {
// type master;
// file "/var/named/xyzdomain.net.db";
// };

~~~


6. Save and Close the Configuration File
After removing or commenting out the duplicate zone entries, save the file and close the editor.

 

7. Re-Validate the Configuration
Once the duplicates are removed, validate the configuration file again by running:

~~~
named-checkconf /etc/named.conf

~~~


8. Restart the BIND Service
If there are no more errors, restart the named service to apply the changes:

~~~
systemctl restart named

~~~


9. Verify the Service Status
Finally, confirm that the named service is running correctly by checking its status:


10. systemctl status named
By following these steps, you should be able to resolve both syntax and duplicate zone definition errors in the /etc/named.conf file, ensuring that your DNS configuration is correct and functional.

  • cpanel server, DNS server, bind service
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to reset SSH port back to default port 22?

In some situations most of us may come across a problem that we are able to log into the WHM but...

How to setup the root login alert notification email?

Its very important to keep a check on your servers and who logs into the server, From security...

How to enable Open SSL on WHM?

Before enabling open SSL, you can check whether it is already enabled on your server. Please fire...

How to install mod_pagespeed on WHM?

'mod_pagespeed' is module of Apache which is nothing but plugin which is used for compressing the...

How to enable Hot Link Protection in cPanel?

To avoid other sites to use your website's bandwidth, you can enable the hot link protection....

Powered by WHMCompleteSolution