.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:
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:
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.
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.
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.comBy 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\.hostsAt 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/flushdnsI 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.

