In this tutorial, I’ll show you how to hide your websites IP address with Cloudflare.
If you self-host your website, a simple DNS lookup of your domain could reveal your networks IP address.
To hide your IP address, you can use Cloudflare, which acts as a proxy between your website and the internet. A DNS lookup would show Cloudflare IP addresses rather than yours.
Sign up and add your domain to Cloudflare
Sign up to Cloudflare, then click ‘Add site’ from the menu bar
Enter your domain and select ‘Quick scan for DNS records’, then click ‘Continue’.
On the next page, scroll down and select the free plan and click ‘Continue’
Cloudflare will give you nameservers, which you will need to point your domain to, in your registrar account. Cloudflare provides instructions on how to change your domain nameservers.
Once you’ve added your domain, go to the DNS page.
All your previous DNS records should be imported, but double-check to see if any are missing.
Make sure your A records are set to ‘Proxied’.
Now your domain will be proxied, and a DNS lookup will show Cloudflare IP addresses. (Although it might take some time for DNS records to propagate)
Automatic IP updates
Your network will likely have a dynamic public IP address, especially if you are setting this up on a home network. This means that your IP address can change over time.
If your IP address changes, your website will become unavailable as the Cloudflare DNS record will become outdated.
To overcome this, we can use ‘ddclient‘. ddclient runs on your server, connects to your Cloudflare account, and checks for IP changes every 5 minutes. If an IP change is detected, the IP address on your Cloudflare account is changed.
Below are the steps to install ddclient on Debian.
Get Cloudflare API token
First, you’ll need to get an API token for your Cloudflare account to allow ddclient to connect to your Cloudflare account.
Visit the ‘Overview’ page on your Cloudflare account and scroll down until you see ‘Get your API token’ on the right side of the page.
Click on the link to open your API Tokens page
Click ‘View’ next to ‘Global API key’
Enter your password and complete human verification.
Keep the key open for now.
Install ddclient
To install ddclient use:
sudo apt install ddclient -y
You can just keep pressing enter for these steps:
Now open the ddclient configuration file:
sudo nano /etc/ddclient.conf
Remove the configuration text
Add the following:
protocol=cloudflare
use=web, web=ipify-ipv4
login=[your email]
password='[your Cloudflare API key]’
zone=[your domain]
[your domain]
Make sure to change the information in square brackets to your own, and leave no space between lines
Like this:
Press Ctrl+x, y, and enter to save
Now restart ddclient
sudo service ddclient restart
Now your web server will automatically update your domain when there’s an IP change.
Issues
If anything goes wrong while trying this, or you have any questions regarding this tutorial, please leave a comment, and I’ll try to get back to you, or alternatively, leave a post on the forum.
No responses yet