Altering hostname-IP mapping within a browser

by Ale   Last Updated June 13, 2019 10:00 AM

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).



Answers 1


In Chromium, you can use the --host-resolver-rules option to specify a list of mappings.

For example:

$ chromium \
  --user-data-dir=/tmp/some-temp-dir \
  --host-resolver-rules='MAP host1.example.com 127.0.0.1, MAP host2.example.com 127.0.0.1'
mmoya
mmoya
June 13, 2019 09:21 AM

Related Questions


Updated November 29, 2017 03:00 AM

Updated March 31, 2019 22:00 PM

Updated May 04, 2017 00:00 AM

Updated June 02, 2017 17:00 PM

Updated March 05, 2019 09:00 AM