Applicable to:
- cPanel & WHM
Question
How to find the best DNS resolver and save it in WHM?
Hosting providers and data centers often add DNS resolvers tied to their own network to the /etc/resolv.conf file. These resolvers usually work, but they may stop responding for a short time, for example, when port 53 is closed and dig cannot connect:
# dig google.com
CONFIG_TEXT: <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> google.com
;; global options: +cmd
;; connection timed out; no servers could be reached
While a resolver is down, the server cannot resolve external domains, which can affect email sending and SPF and DKIM validation. A public DNS resolver may offer faster response times or better uptime.
Answer
- Log into the server via SSH.
-
Note: Scripts mentioned in cPanel articles are not supported by cPanel technical support. If you have issues with the script, contact a qualified system administrator.
Save the following script as
/root/resolver_test.sh. It works on any server withbashanddiginstalled:#!/bin/bash DOMAIN=cpanel.net; echo "Testing common resolvers and calculating average response times by testing each resolver 3 times. This may take a few minutes" echo for resolver in 8.8.8.8 4.2.2.2 1.1.1.1 208.67.220.220 156.154.71.1 216.146.35.35 do echo $resolver for reps in {1..3} do dig $DOMAIN @$resolver | awk '/time/ {print $4 " ms"}' sleep 3 done |awk '/ms/ {sum+=$1} END {print "Ave time: ",sum/3, " ms"}' echo done -
Run the script. Each resolver is tested three times, so it may take a few minutes:
# bash /root/resolver_test.sh
- Compare the average response times in the output and select the resolvers with the lowest latency. Response times depend on the server's location and network, so results vary from server to server.
-
Create a backup copy of the resolver configuration file:
# cp -a /etc/resolv.conf /etc/resolv.conf.bak
-
Note: Some public resolvers do not allow spam RBLs to function on the server.
Log in to WHM as root, navigate to Home > Service Configuration > Exim Configuration, and ensure your server has no spam RBLs enabled.
- In WHM, navigate to Home > Networking Setup > Resolver Configuration.
- Click Proceed.
- Update the IP addresses to use the resolvers with the lowest average latency.
- Save the new configuration.
For more information about the resolver settings, refer to the Resolver Configuration documentation.
Comments
0 comments
Article is closed for comments.