Bobcares

EdgeRouter Cloudflare DNS | Configuration and setup

by | Oct 12, 2022

From this EdgeRouter Cloudflare DNS article let’s learn how to configure Dynamic DNS on the EdgeRouter. With help of our Server Management Services, Bobcares offers solutions regarding your Cloudflare and server-related queries.

Setting up a Ubiquiti EdgeRouter Cloudflare Dynamic DNS

EdgeRouter Cloudflare DNS

Requirements

 

Before getting started, you will need the latest firmware for your EdgeRouter device, a CloudFlare account, and a domain configured to use Cloudflare for DNS

 

Once all the requirements are configured, we will get started with the setup.

 

Set up A record for the domain

 

You need A record configured in Cloudflare for the domain so that it points to your router. Temporarily you can set the IP address for this record to “216.58.219.196” which is one of the IP addresses for google.com.

 

Once the router is configured the address will be updated automatically.

 

Get your Cloudflare API key

 

Cloudflare uses an API key to authenticate requests to the API. You will require this key to configure the router’s dynamic DNS client.

 

Configure the router’s dynamic DNS client

 

Now that the DNS record is added, the next step is to set up the dynamic DNS client to the router. There are two ways of configuration type: By console command line, and the config tree in the web UI.

 

It’s up to you how you wish to use them, both methods get the same result. If you are not familiar with SSH or using the console commands it’s best to stick with the web UI config tree.

 

We will use the following details in this Article:

 
  • Domain: domainname.com
  • Dynamic DNS subdomain: dyn.domainname.com
  • Cloudflare username: cloudflare@domainname.com
  • Cloudflare API key: 8aa10fbd56bfea6820d28f25b3b955573557
  • Network port/interface: eth0
 

Note that the Cloudflare API key is used as the password, make sure to change them when you execute the command. This key is found in your Cloudflare profile.

 

Console

 

If you wish to continue with the console route then use this section or skip to the web UI section.

 

First SSH to your router’s private IP address and enter the login credentials you use into the web UI.

 

Once connected, put the router in configuration mode by typing:

 
configure
 

Set a custom dynamic DNS service entry for Cloudflare and configure the service to use the Cloudflare account.

 

Review each below command that you may need to change to match your specific configuration before running:

 
set service dns dynamic interface eth0 service custom-cloudflare protocol cloudflare
 

set service dns dynamic interface eth0 service custom-cloudflare server www.cloudflare.com
 

set service dns dynamic interface eth0 service custom-cloudflare host-name dyn.domainname.com
 

set service dns dynamic interface eth0 service custom-cloudflare login "cloudflare@domainname.com"
 

set service dns dynamic interface eth0 service custom-cloudflare password "8aa10fbd56bfea6820d28f25b3b955573557"
 

set service dns dynamic interface eth0 service custom-cloudflare options "zone=domain.com use=web ssl=yes"
 

Make sure to change the given example domain name with your website/domain and change the Cloudflare password to the Cloudflare API key found in your Cloudflare account.

 

Later commit your changes >> save to the persistent router configuration >> and exit configuration mode:

 
commit
save
exit
 

Check the status of your client configuration:

 
show dns dynamic status
 

You will get a result as shown below:

 
interface    : eth0
ip address   : YOUR_IP_ADDRESS
host-name    : dyn.domainname.com
last update  : Tue Jun 1 01:13:24 2022
update-status: good
 

If you check the A record in your Cloudflare account, you will notice that the IP address has been updated.

 

Web UI

 

If you executed steps in the console part then you can skip this section. Otherwise, proceed with the Web UI procedure.

 

Click on the “Config Tree” tab >> service >> DNS >> dynamic >> interface.

 

Add a new interface entry using the name of the WAN connection interface. Example: eth0. Click “Update List”.

 

Drill down into the newly added interface entry on the left and then the service subentry.

 

Next, click the “Add” button to create a new service entry and call it custom-cloudflare >> click “Update List”.

 

Access the newly added custom-cloudflare entry on the left >> Click “Add” next to host-name and provide your dynamic DNS subdomain. Example: dyn.domainname.com.

 

Fill in the details asked in the form fields as follows:

 
  • login: Your Cloudflare username. Example: cloudflare@domainname.com
  • options: Update the following line with your domain, and paste it into the field: zone=domainname.com use=web ssl=yes
  • password: Your Cloudflare API key
  • protocol: cloudflare
  • server: www.cloudflare.com
 

Click “Preview” at the bottom of the screen >> click “Apply” when prompted >> Navigate back to the custom-cloudflare service on the left.

 

When you check the A record in your Cloudflare account, it may not be updated with your IP address. If this is the case you will need to force change your router to do an update.

 

Go to the Services tab at the top of the screen >> choose the DNS sub-tab >> Finally click “Force Update” at the bottom of the screen. You’re done!

 

[Looking for a solution to another query? We are just a click away.]

 

Conclusion

The router will now monitor your public IP address and update the A record in Cloudflare if that IP address ever changes. 

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.