Mailgun & Cloudflare

enter image description here enter image description here

You own a domain name and you use Cloudflare to proxy your websites, services or something else and now you want to have an email address with your new shiny domain name. Cloudflare doesnt support mail forwarding, some registrars have their own forwarding system but if you use Cloudflare then we need to look at Mailgun.

  1. Sign up for a free account at Mailgun.
  2. Add your domainname to Mailgun enter image description here
  3. Once added you need to verify you own the domain and setup the relevent records. Head over to Cloudflare and create the records, they will look similar to the below image. enter image description here This is what you will end up with. (Make sure the email CNAME status is the grey cloud!) enter image description here
  4. Head back to Mailgun. You will need to give the Records we created above some time to propogated across the internet. You can check this by clicking 'Check DNS Records Now' enter image description here
  5. Creating Routes. In Mailgun we need to specify routes or email addresses. This will define the recipient email and the action to take.

enter image description here

You can create a number of routes or you can create a 'catch all' or both. Priority is like rules, It will match the lowest priority first (lowest number), so if you set a 'catch all' rule set a high number priority e.g. 100. That way it will attempt to match everything else first.

  1. Finally in Mailgun we also need to validated our personal email address, hotmail, gmail or whatever. Head into Account Settings and then Authorised Recipients. Add your email address which will send a link to your email which you need to validate.

enter image description here

Once the DNS settings have been updated and you have validated your email you should now be able to receive any emails sent to * which will appear in your hotmail or gmail account.

Setting up a Dynamic DNS (DDNS)

enter image description here

Dynamic DNS (DDNS or DynDNS) is a method of automatically updating a name server in the Domain Name System (DNS), often in real time, with the active DDNS configuration of its configured hostnames, addresses or other information. (Wikipedia)

In English - a DDNS is needed when you have a DHCP ISP (WAN IP). If you restart your router you will get a different external IP (WAN IP). This is no good if you want to be able to access your services externally as everytime your IP changes you will have to remember it. This is where DDNS steps in.

A DDNS gives you a web address which resolves your WAN IP even if it changes. There are many services out there, most of them free!

For this guide I will use No-IP as a DDNS. Head over to and create an account.

enter image description here

Click on 'Dynamic DNS (Free)' on the left side and then click hostname.

enter image description here

Hostname - whatever you want for your domain name Domain - dropdown list, I left it on IPv4 Address - your WAN IP, should already be filled in.

No we have a DDNS domain setup we need a way to automatically update the address with the WAN IP.

For the next part there are a few different ways to update the IP for the DDNS.

The Router

Some routers have a DDNS update client built in. The page below is from my Unifi Router

enter image description here

Here is a BT Router DDNS page

enter image description here

Once this step is setup your router will update the DDNS with your WAN IP everytime it changes.


There is also a client you can download and have run on a PC which updates the IP. Download it from No-IP Client

When setting it up, use the account settings you used when creating the No-IP account

enter image description here

There are other ways, however for now I will leave it with the 2 options above.