Computer Hope

Microsoft => Microsoft DOS => Topic started by: Fufu on July 23, 2021, 02:45:07 AM

Title: Auto update IP address in Windows Hosts file when failed
Post by: Fufu on July 23, 2021, 02:45:07 AM
Hi Everyone,

Is there a such windows batch file or script that can monitor the hostname connection alive. If the ping of hostname failed/down, it will auto update the IP address in the windows hosts file.

Example:

In windows/drivers/etc/host

IP address      Hostname

192.168.1.100   SQLServer

Let say we do a ping on SQLServer and it failed, batch file will update the IP address from 192.168.1.100 to 192.168.2.100 and now the file should changed to:

192.168.2.100   SQLServer

And again when ping failed on SQLServer, it will auto switch back to 192.168.1.100   SQLServer in the Host file.
Title: Re: Auto update IP address in Windows Hosts file when failed
Post by: DaveLembke on July 23, 2021, 07:00:31 PM
At a prior IT Job I had I needed the networks to be able to self heal for problems between 7 sites with multiple paths to share data between the sites. I bought Alert Ping Pro and it monitors for failed connection and upon failed ping connection you can tell it to do a number of things of which one of the things was to execute batch files or EXE's that I created in C++. The Batch or compiled C++ programs I had would reboot hung point to point private DSL Modem Bridges as well as redirect network traffic through an alternate path to maintain data communications between 7 food stores.

Because my employer gave me the ability to buy software I went that route, however you could run a batch in a loop and then depending on what is the issue you can alter the hosts file at that system.

http://www.bestshareware.net/alert-ping.htm