Testing with your hosts file
This page is part of Step 5: Set up Network protection and test it.
Before you change public DNS, you can test a site through the sentry on your own computer. You do this by mapping the domain and its www name to the sentry's public IP address in your hosts file. Only that computer is affected; everyone else still reaches the site the usual way.
You turn Website protection on or off for the domain on the Domains page in the portal, the same as after you point DNS.
The sentry's public IP address
In the portal, open Clusters, expand the cluster and click the sentry's name. Public IP shows the sentry's address, with a Copy button. Or, on the sentry, run:
ip -br addr
Use the public IPv4 address you'll later put in the domain's A record. See Network and IP addresses.
The examples below use the documentation address 203.0.113.10 and example.com. Replace them with your sentry's public IPv4 address and the domain you're testing.
If the domain has a public AAAA (IPv6) record that still points at the origin, your browser may use IPv6 and bypass the hosts file entry. Add a line for the sentry's IPv6 address as well (ip -br -6 addr on the sentry), or remove that AAAA record first.
Windows
-
Open Notepad as an administrator: right-click Notepad and choose Run as administrator.
-
Open
C:\Windows\System32\drivers\etc\hosts. If the file doesn't appear, set the file type filter to All files. -
Add these lines at the end, using your sentry's address and domain:
203.0.113.10 example.com203.0.113.10 www.example.com -
Save the file.
-
Open Command Prompt and flush the DNS cache:
ipconfig /flushdns -
Close and reopen your browser, then visit the site.
macOS
-
Open Terminal and edit the hosts file:
sudo nano /etc/hosts -
Add these lines at the end, using your sentry's address and domain:
203.0.113.10 example.com203.0.113.10 www.example.com -
Press Control+O then Enter to save, and Control+X to exit.
-
Flush the DNS cache:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder -
Close and reopen your browser, then visit the site.
Linux
-
Edit the hosts file:
sudo nano /etc/hosts -
Add these lines at the end, using your sentry's address and domain:
203.0.113.10 example.com203.0.113.10 www.example.com -
Save and exit (in nano, Control+O then Enter, then Control+X).
-
If your system uses systemd-resolved, flush its cache:
sudo resolvectl flush-caches -
Close and reopen your browser, then visit the site.
Check that it's working
Browse to the domain, including www if you use it. The site should load through the sentry.
Browsers often cache DNS, so if you still see the old site, close the browser completely and open it again. You can also check that the name now resolves to the sentry, for example with ping example.com (it should show the address you added).
On Domains, the domain's traffic figures update within a few minutes once requests are reaching the sentry. See Check it's working in the portal for what to look for, and Point DNS at your sentries for what to do when you're ready to change public DNS.
Remove the entries afterwards
When you've finished testing, remove the lines you added, save the file, and flush the DNS cache again (the same command as above for your system). Close and reopen your browser so it doesn't keep using the test address.
If you leave the entries in place, that computer will keep going to the sentry even after you change your mind, and it can be confusing later when public DNS and the hosts file don't match.