SwitchHosts!



SwitchHosts
Tool to switch the Windows HOSTS file for VPN connections using IP translation. It can hold several HOSTS settings which can be switched from the system tray by clicking the SwitchHosts icon.
Features
-Switch between 2 or more HOSTS configurations
-Open VPN connection program when HOSTS configuration changes
-Optionally keeps your Windows session unlocked
-Application hides in the Windows system tray
Description
Due to company policy the VPN tunnels to customers for remote support changed. This had big influence on the way the on-site engineers connect to the customers servers and devices during remote support from home in the weekends.
With the old VPN between the company and the customer the on-site engineers could connect to their company and use the VPN tunnel to the customer. For accessing the servers, automation and devices the same IP addresses could be used as being on-site.
The new VPN tunnel to the customer uses double NAT (Network Address Translation). That is why for remote support a different range of IP addresses is used as opposed to being on-site at the customer.
One way of dealing with this situation was reconfiguring all tools and programs on the engineers laptop every time he switched between being remote or on-site. Another solution would be accessing the customers network using hostnames but the lack of a DNS server prohibited this option. But there is a way that allows the use of hostnames even without a DNS server: the Windows HOSTS file. The Windows HOSTS file is a list with IP addresses with their hostnames and can be found in the folder c:WindowsSystem32DriversEtc. Only downside is that whenever the situation changes (on-site/remote) the HOSTS file needs to be changed. This system tray application does the trick in no time.
Just choose the setting you need from the SwitchHosts system tray menu and the corresponding HOSTS file will be copied to the c:WindowsSystem32DriversEtc folder, overwriting the old HOSTS file.
As from version 1.1 SwitchHosts can also popup the VPN connection whenever a different HOSTS file is selected. In version 1.2 an option is added to keep Windows unlocked/awake not to loose the VPN connection.
The first time SwitchHosts is started it elevates itself by registering with the highest privileges. The Windows User Account Control (UAC) will prompt for confirmation. As long as it is started from the same folder this confirmation is not needed after the first run.
Screenshots
SwitchHosts about box and system tray menu
Commandline options
No command-line options available.
Configuration file settings
[NoSleep]
NoSleepKeep Windows session active (1 = Enablede, 0 = Disabled)
DelayTimeNumber of seconds between mouse moves (0 ... 300)
[VPNclient]
WindowTitleTitle of the VPN connection program
ProgramExeFull path to the VPN connection program
HOSTS file examples
#Onsite
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# EXAMPLE HOW TO SETUP YOUR HOSTS FILES
# YOU CAN ADD AS MANY ROWS AS YOU NEED
10.163.60.36 DBSERVER1
#172.19.11.24 DBSERVER1
10.163.60.37 DBSERVER2
#172.19.11.25 DBSERVER2
#VPN
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# EXAMPLE HOW TO SETUP YOUR HOSTS FILES
# YOU CAN ADD AS MANY ROWS AS YOU NEED
#10.163.60.36 DBSERVER1
172.19.11.24 DBSERVER1
#10.163.60.37 DBSERVER2
172.19.11.25 DBSERVER2

The # options out a row. Hostname DBSERVER1 in the first example is IP address 10.163.60.36 and in the second example 172.19.11.24.
Make sure to put a unique name in the first row for the HOSTS files preceded with a #. This will result in Windows ignoring the first row and SwitchHosts to recognize the file and to display the name in its system tray menu.
Save your HOSTS files using the same name as set in the first row in the folder 'SwitchHostshosts' with the extension '.hst'. In the above example this would be 'SwitchHostshostsOnsite.hst' and 'SwitchHostshostsVPN.hst'.
Version history
v1.0Initial setup
v1.1HOSTS file configurations in SwitchHosts sub folder
Added starting VPN connection program popping up if HOSTS configuration is changed
v1.2Added 'No Sleep' option
Known bugs
No known bugs.
Future enhancements
None.
Download
Please read the legal notice first, allthough you probably heard it before :)

Copyright 2018 DULMEN.net. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY DULMEN.net 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL DULMEN.net OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of DULMEN.net.

You can download SwitchHosts as a compressed folder containing all files needed. No need to install the software, just unzip, adapt the configuration file SwitchHosts.ini and run SwitchHosts.exe.
SwitchHosts is free for personal and bussiness use and is free to distribute as is as long as the program is not altered and accompanied with the SwitchHosts text file.
VersionFileSize
v1.2SwitchHosts_v1.2.zip425,55 KB (435764 bytes)
v1.2SwitchHosts_v1.2.7z350,4 KB (358806 bytes)
v1.1SwitchHosts_v1.1.zip350,47 KB (358886 bytes)
v1.1SwitchHosts_v1.1.7z346,53 KB (354851 bytes)
DULMEN.net © v8 2018 - Designed & written by Arno van Dulmen

Homepage: https://swh.app

SwitchHosts is a Hosts file switcher freeware for Windows 10/8/7 that allows you to change your Hosts file with a click. Useful if you need to have two Hosts file on your PC. Links Detail View. Details — ( 209 ) Previous Webpack config tool; Next How to stop using console.log.

SwitchHosts is an App for managing hosts file, it is based on Electron, React, UmiJS, Chakra UI, CodeMirror, etc.

Screenshot

Features

  • Switch hosts quickly
  • Syntax highlight
  • Remote hosts
  • Switch from system tray

Install

Download

You can download the source code and build it yourself, or download the built version from followinglinks:

Backup

SwitchHosts stores data at ~/.SwitchHosts (Or folder .SwitchHosts under the current user's homepath on Windows), the ~/.SwitchHosts/data folder contains data, while the ~/.SwitchHosts/configfolder contains various configuration information.

Develop and build

Development

  • Install Node.js
  • Change to the folder ./, run npm install to install dependented libraries
  • Run npm run dev to start the development server
  • Then run npm run start to start the app for developing or debuging

Switchhosts

SwitchHosts!

Build and package

  • It is recommended to use electron-builderfor packaging
  • Go to the ./ folder
  • Run npm run build
  • Run npm run make, if everything goes well, the packaged files will be in the ./dist folder.
  • This command may take several minutes to finish when you run it the first time, as it needs timeto download dependent files. You can download the dependenciesmanually here,or Taobao mirror, then save the files to ~/.electron. You can check the Electron Docs for more infomation.

Switchhosts Firefox

Copyright

Download Switch Hosts

SwitchHosts is a free and open source software, it is released under the Apache License.