At work, we may have to connect to multiple environments, including mock environments, back-end environments that provide interplay, test environments, pre-release environments, production environments, and so on. We need to switch Hosts frequently to access different environments for debugging and verifying problems.

This article recommends two small tools to modify the host file, no longer need to directly modify the host file, completely get rid of the trouble of not finding the host file, frequently modify the host file.

The role of the host file

Hosts is a system file without any extension. This file stores the mapping between domain names of common web addresses and their CORRESPONDING IP addresses.

When accessing a website, the browser checks whether the mapping between the domain name and THE IP address exists in the Hosts file before making a DNS request. If yes, the browser directly accesses the network specified by the IP address. If no, the browser sends a resolution request to the DNS server.

SwitchHosts

SwitchHosts is a small tool for managing and quickly switching Hosts configuration. It is very easy to use. Supports Windows, macOS, and Linux. Open source: github.com/oldj/Switch… , you can download the version you need.

Click the plus sign in the lower left corner to create a rule and set the rule name. The rule can be a local rule, a remote rule, or a combination rule.

Enter the CORRESPONDING IP address and domain name in the blank on the right of the local rule.

The remote rule can place the host file in remote management, where the remote address is provided directly. In addition, you can set the automatic update interval to facilitate the team to share the same set of rules and maintain them in a unified manner.

Combining rules You can combine multiple existing rules to easily combine required configuration combinations.

In use, you only need to switch by one key. Multiple sets of rules can be enabled simultaneously.

Chrome extension Host Switch Plus

Host Switch Plus is a Chrome plugin that is also easy to use.

When used, as long as you click on the green icon in the upper right corner of Chrome, Popup will list all configured IP and domain name, you can operate in real time, one key to open and close, you can also click Tags, open and close all rules corresponding to the current Tags.

Edit is also very convenient, enter the edit page, you can add or batch add/delete. Tags are also supported to distinguish between different environments.

After downloading the plug-in, you can reply to HostSwitchPlus in the background of the public account.

Welcome to my public account “front-end xiaoyuan”, I will update the original articles on it regularly.