Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Override Web Settings | .hosts File | Fake Any Domain Name (for Windows)

.hosts file - IP / Domain Overrides

I use this all the time when launching new servers at work or for personal projects. When a domain name is pointed at a server, the DNS records are setup to point either to a nameserver, or to an IP address directly, or similar. Either way, the domain points to an IP you can override at some point. If I want to make the domain 'fakedomaindemoexample.com' go to a different IP, I can do so by editing my .hosts file and adding an entry like this:

Code
192.168.1.1 fakedomaindemoexample.com

By doing so, the fakedomaindemoexample.com website will then go to that new IP address when visited in my web browser, even though I don't own that domain. Now, there is more to it than this - for example, if I point any site at an IP, the server that uses that IP will need to be setup to receive that request. If I take over fakedomaindemoexample.com, then I would need to setup nginx or apache to receive that domain & serve something in response. Of course, for my personal projects this is the main goal - I already will have my site running on the server, but instead of waiting hours for DNS to propagate (the domain to point to my IP naturally), I can instead skip ahead and use my .hosts file to override the settings & start using my domain to show the site immediately. Then once the DNS truly propagates, I can remove the IP/domain from my .hosts file and get SSL setup.

.hosts file location:
Code
C:\Windows\System32\drivers\etc\.hosts
I usually will start by opening Notepad, running as Administrator. Then I will navigate to the etc folder. You may need to toggle the 'All Files' option if your notepad (file open window) is set to look for .txt files.

At the end of my .hosts file I can enter domain and the new IP like the fake domain demo example above.
Once done, in command terminal for Windows you'll want to run this to reset your local networking. Please also note that if you have the real site open in your browser, it may be cached and not respect your .hosts file. Similarly, sites like Google or other known services may not fully respect hosts file depending on browser.

Code
ipconfig/flushdns



I hope this helps you in some way. As a dev, you can use your new domain immediately, and for everyone else you can find ways where this may be helpful - letting you use a domain in a web browser to show your server's most up to date version.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by AeonSep 1, 2023 10:24 AM 0 152 Sep 1, 2023 10:24 AM
Last Post: Aeon
by Dread.ReaperMar 31, 2023 09:55 AM 0 98 Mar 31, 2023 09:55 AM
Last Post: Dread.Reaper
by balvant baldaniyaOct 19, 2015 11:48 AM 0 193 Oct 19, 2015 11:48 AM
Last Post: balvant baldaniya