Change Hosts

The ultimate "Hosts File" editor for Mozilla Firefox!
Change Hosts is a complete Hosts File editor, commonly used by developers to force a domain name resolution to a specific IP.

Overview

Most developers usually takes advantage of Operation System Host File (commonly known as "hosts") to "trick" the S.O. and the browser to load websites and webservices from another server than the real production one.

It's a very easy approach to be able to use the production host name of your site or service while pointing your computer to another server (staging, Q&A, etc).

Some companies uses this strategy a lot, making a little dificult for developers to manage the huge amount of host names and IPs. In some cases developers needs to take care of thousands lines divided by several files. Everytime a server needs a different IP is a very boring job to update all these files.

With this problem in mind, we've created Change Hosts. A very easy to use tool that can make this job more efficient.

Main features

How to use it

Warning! If you're migrating from an older version, please check this page.

Installation

Install it via Mozilla Add-ons site or via Firefox Add-on manager.

You have 2 options to access the add-on:

  1. Activate the Firefox Add-on bar (Options > Add-on bar)

Activate status bar

You'll see an icon (blue notepad) next to a 'Change Hosts' text on the bottom of the browser;

  1. The other option is to use a button that is available on the browser toolbar.

The button is added on the first time you install the Add-on on your browser;

First use

You'll need to set up some parameters, specially:

Locations

Hosts root directory

Here is where all the files will be stored. Select a folder that firefox is able to write to it.

Tip! Change Hosts uses a regular folder on your computer, so you can use a SVN/Git folder or a network folder (like NFS) to share the files between all developers of your project.

'Hosts file' path

This is the S.O. hosts file or other destination you'd like. It's filled with your S.O. default path on the first run. Firefox need rights to write to this file.

Important: If you don't use the default S.O. hosts file (C:\Windows\System32\drivers\etc\hosts for Windows or /etc/hosts for Linux / Mac) you'll need some adjusts.
Adjusts you might need
For example, if you use the file c:\project\hosts as Hosts file path, Change Hosts will write just in it, so you need to make it's content to go to real hosts file.

 

Some Change Hosts users use Symlinks replacing the real S.O. host file with a Symlink to the file that Change Hosts is writing.

For more information about Symlinks, see this site: http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista

Other users write a .BAT file that copy the content from one file to another.

Change Hosts checks the permission it need to do its job and inform you using this icons:

OK
Fail on read, write or execute
File not defined or permission couldn't be verified

 

Post processing

This is a very useful option for who don't want or can't write directly to S.O. hosts file. After Change Hosts writes to the file that you informed on 'Hosts file' path field, it can execute a file. You can set, for example, 'Host file' path to a temporary file and then copy the content to the real 'Hosts file' using a shell script.

A great use for this is to run a script to invoke ipconfig flush command on Windows. Create a .BAT file with the following command: ipconfig /flushdns and configure it as the post processing file.

DNS Flusher integration

Change Hosts will show you eighter DNS Flusher is installed on your browser or not. If so, you can turn this integration on and after each host changing Change Hosts will Flush the DNS cache as well.

Status bar configs

Configs to control how Change Hosts appears on your status bar.

Colors:

You can change the default color (Black) to another on you preffer.

Another option is to use a Regular Expression to set a different color based on the host file name, add as many regex as you want. They are unique, so you cannot have two or more regex with the same content and different color.

Adding a regex:

Where it's applied:

Another option that I'll talk about later is to set a color for a folder or for a file.

Managing your host files

FIrst of all, let's take a look on the 'Host' tab:

Current: The current selected hosts file;

Hosts selection:

Folders: Shows every folder inside the 'Hosts root directory'. Use folders to organize your Hosts files, like a folder to each product you manage, each environment or whatever you like;

Files: Shows every "*.hosts" file inside the previously selected folder. Select a file and click on "Change" button to use this file.

New hosts button: Create a new Hosts file

Change button: Get the content of selected file and save on the file chosen on 'Hosts file path'. CAUTION: The existent content of the destination will be replaced!

Clear button: Erases the 'Hosts file path' content;

Edit: View the content of the file selected on 'Hosts selection - Folders - Files';

View parsed: As said before, Change Hosts supports a include pattern called 'Hostesse'. Better explained with an example:

File 1: common.hosts

#common server
192.168.0.1 my-common-server.com

File 2: qa.hosts

#environment - qa
{ common }

10.0.0.1 my-site.com

File 3: production.hosts

#environment - production
{ common }

189.0.0.1 my-site.com

Will result in:

File 2:

#environment - qa
#common server
192.168.0.1 my-common-server.com

10.0.0.1 my-site.com

File 3:

#environment - production
#common server
192.168.0.1 my-common-server.com

189.0.0.1 my-site.com

View parsed is a mode that allow you to see how the file will be after being parsed. It's not possible to edit any file while Parsed mode is enabled;

Close after change: Eighter Change Hosts window should be closed or not after changing the hosts;

Cancel: If a change has been made on the file, Cancel will restore the original file content;

Save: Saves the changes made on the file;

Save and Close: Saves the changes made on the file and change the 'Hosts file' to the selected file.

Colors: Besides all coloring features you have seen on the first tab, Change Hosts also support setting a color for folders and files.

To set a color, click on the folder or file you want and click on 'Set color':


...

Color precedence:

  1. If the file has a color, it'll be used;
  2. If the folder where the file is stored, this color will be used;
  3. If there's a regex that matches the files name, the 'Regex color' will be used;
  4. If none of the above options is true, the default color will be used.

Color indicator: There's an indicator () next to Regexes, Folders and Files that indicates which color will be used.

Expand / Collapse: When you have a big tree of folders, it' difficult to get right to the folder you want.

Right clicking on a folder that has another folder inside, there's an option to Keep this folder collapsed everytime you load Change Hosts.

It's very useful when you have a 'common folder':

On the image above you can alse see other features: Create new hosts files, Delete folders and Clear the folder color.

And you have similar for files as well: