Manipulating a hosts file

As you get older three things happen. The first is your memory goes, and I can’t remember the other two…

Sir Norman Wisdom


Dear Process Wise Friend,

Manipulating a hosts file

By Taylor Dunn


The hosts file is an alternative to using DNS and is the default location that the Windows OS uses in name resolution. It must be setup in each individual server and is particularly useful in connecting to servers outside of the domain or where no domain is setup. In general a hosts file is setup with the IP address, server name, and a description.     <Server Name>          #<Description>


Windows doesn’t care whether <Server Name> is the actual server name or whether it is a made-up name. In projects where a redundant OPC server is kept and is only used at scheduled times such as patching and maintenance you may consider this approach when setting up hosts files to make data collection and switching between source servers easier. Instead of using the computer name use an alias like, “Active_DCS” as the server that is being polled and “DCS_1” and “DCS_2” for IP address references.        DCS_1        #Primary DCS Server        DCS_2        #Secondary DCS Server        Active_DCS        #Active DCS Server


With this method you could change the IP address in the Hosts file of the Active DCS Server and restart your historian, it then starts collecting from the redundant server.


A similar approach can be used when upgrading a system. Often programs are configured to connect to a remote computer by name instead of IP address. The IP address in the hosts file can be changed to any machine’s IP address while still using the old <Server Name>. The software will still work without being reconfigured.


For the <Description> after the # symbol, you can put other useful information or notes there and Windows will ignore it because it is commented out. I like to put the OPC Program ID with the description so I can reference it quickly.