How to test CloudFlare without changing your domain's name server
Asked Answered
F

2

25

How can you test CloudFlare without changing your domain's name server?

I would not want to change my domain's name server and wait hours for propagation only to find out there is a issue with the DNS settings.

Can you spoof a nameserver or something on a local hosts file?

Fayth answered 30/7, 2012 at 6:47 Comment(0)
G
39

Yes, you should be able to test before you change your name servers. Here's what to do:

  1. Signup at https://www.cloudflare.com/sign-up and complete the signup through Step 4 when you're asked to update your name servers.
  2. Note the two name servers you are provided which will be in the format [name].ns.cloudflare.com.
  3. From a terminal, do a lookup to get the IP addresses your domain has been assigned. In Linux/Unix it'd be: dig @[name].ns.cloudflare.com yourdomain.example
  4. Repeat step 3 with all the subdomains you want to check.
  5. Update your localhost record to resolve the domain(s) to the IPs you found with the lookup.
  6. Browse the site from the same machine where you did the localhost update and traffic should pass through CloudFlare.

While this will work for a while, after 24 hours CloudFlare's system may detect that your name servers haven't updated and, in some cases, may return an error. However, this technique should allow you basic testing before you update your name servers.

Glasswork answered 30/7, 2012 at 7:1 Comment(9)
Thanks, cloudflare not working yet, but at least found out before going live. will troubleshoot via tech support.Fayth
By "update your localhost record", do you mean modifying /etc/hosts on UNIX?Olmos
I get "ERR_SSL_PROTOCOL_ERROR" when trying thisNickname
@Nickname It seems the answer to this question may answer the ERR_SSL_PROTOCOL_ERROR problem: https://mcmap.net/q/538743/-cloudflare-rails-ssl-errorCopyread
BTW, for those that need it, you can do a dig operation online digwebinterface.com and the windows hosts file is found C:\Windows\System32\drivers\etc\hosts where you just add a line (Ex. IPfromDig myawesomesite.com www.myawesomesite.com) - make sure you open the hosts file as admin if on windows (aka, open notepad first as admin and use notepad to open the hosts file)Gargle
I know old thread but useful to clarify that @filmm - yes, that's correct - your local dns record in your hosts file e.g. see here: rootusers.com/how-to-use-the-hosts-file-to-fake-dnsElwell
When I try the above method and then try accessing localhost, I see a page from Cloudflare saying 'Direct IP Access not allowed'. It further says 'A valid Host header must be supplied to reach the desired website.'. When I manually modify the host header for HTTP request, I see the expected page response. But I can test this only for that HTTP resource.Bontebok
If using Windows, you can use the following as an alternative to dig in Powershell 3.0+: Resolve-DnsName -Name [domain] -Server [name].ns.cloudflare.com (credit: https://mcmap.net/q/495801/-dig-dns-lookup-specify-dns-server-on-windows)Iodide
This no longer works, CloudFlare changed their NS behaviour. Maybe this should not be the accepted answer anymore, or it should be updated.Chartist
S
7

To save future users from some headache, the above answer doesn't work anymore: https://community.cloudflare.com/t/ip-on-cloudflare-nameserver-is-not-masked-despite-orange-cloud/76137

From my understanding, you now need to change your nameserver.

Said answered 16/4, 2019 at 2:15 Comment(1)
Link-only answers are discouraged on Stack Overflow, as they are rendered useless if the link stops working for whatever reason. You should edit your answer to include the most important points that are relevant to the question in the answer itself.Palembang

© 2022 - 2024 — McMap. All rights reserved.