A common way to test an existing website on a new server before switching it to production by updating the DNS record is to change the hosts
file on a development machine (/etc/hosts
on *NIX systems, and %windir%\system32\drivers\etc\hosts
on Windows), to have the OS resolve the hostname of the server to the new server. The developer can thus test the new server in real conditions before the actual deployment.
Now, changing the hosts
file also has some downsides, among which:
- the developer might forget to remove the change, with possibly undesired effects on the long term
- the change requires administrative access on the machine
Hence the question: is there a way to do this change only within the browser (for Firefox, Chrome, and/or MSIE)? Looking for Firefox, I've found two or three add-ons, but they all do the same: modifying the OS-wide hosts
file.
I'm looking for a self-contained lightweight solution working on both MS Windows and Linux, that does not require administrator privileges (so I can for example have students do that on their lab PCs), and without any external hardware/services (e.g. a router doing DNS spoofing or a proxy server doing the same).
In Chromium, you can use the
--host-resolver-rules
option to specify a list of mappings.For example:
I found a solution here that works for one IP on a per-Firefox-profile basis.
about:config
.network.dns.forceResolve
to e.g.127.0.0.1