Server Setup

Setup CloudFlare DNS resolution in CentOS/RHEL 7 servers

by , , revisited on

We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

Reliable and fast DNS resolution is essential for running any networked device. Web servers are no exclusion.

How servers benefit from fast DNS?

Improving the DNS resolution speed, will also improve all the server functions which use DNS. This applies to:

  • Websites using external APIs
  • Synchronizing time
  • Any other features requiring DNS resolution. One example would be nginx web server using DNS resolution for its SSL stapling feature

Enable CloudFlare DNS resolution in CentOS 7

Since CentOS 7 uses NetworkManager by default, we can easily enable the great new DNS service by CloudFlare with a few commands only.

We assume that your main network interface is eth0. Let’s start with making sure that the DNS servers sent by DHCP are not used:

nmcli connection modify eth0 ipv4.ignore-auto-dns yes

Now, adjust configuration profile to use CloudFlare fast DNS servers. For IPv4, run:

nmcli connection modify eth0 ipv4.dns,

And for IPv6, you may want to additionally run:

nmcli connection modify eth0 ipv6.dns 2606:4700:4700::1111,2606:4700:4700::1001

Now we have configured our network settings, but they are not yet live. Let’s bring up the use of CloudFlare DNS nameservers:

nmcli connection up eth0 

Wasn’t that easy? Now your server uses the fastest DNS nameservers. And if you don’t trust my word, you can use dnsperftest from our repository to confirm.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: