hostnames

How to Use Hostnames in MIStudio Applications

Hostnames

Many of the MIStudio device server beans, such as a PLC Device Server or a Database Manager, need to be configured with an IP Address or “Hostname” to connect to the device or database. This IP Address can be entered with a static IP address if the project you are building will always be connecting to that specific IP Address. But more times than not you will want to make this IP Address changeable for the deployment platform and location where the IP Address of the device or database is not known at build time.

This is the reason to use a “hostname” for the IP Address configuration (often the bean property is “Hostname”). A hostname is a reference to a value entered in the host table of the operating system and is available for both Windows and Linux-type systems. So if you configure the “hostname” of a device server to be “myplc”, the operating system will translate this hostname “mnyplc” to the IP Address value in the system's hosts file. To make this work the hosts table on the deployment system (and MIStudio development system for testing) must be edited to add this entry.

Note: on most ErgoTech IOT Linux-based platforms there is a function in the configuration utilities to add entries to the system's host file as part of the network configuration.

Host table files are generally protected by unauthorized changes (on Windows since Windows 7) and therefore must be edited using an administrative account. On Windows this file is in the directory C:\Windows\System32\drivers\etc\ and is “hosts” (no extension). Open this file using editpad, notepad++, or similar running as administrator. At the bottom of the file add the IP Address you want to alias, such as “192.168.0.1”, followed by a space or two and then the hostname (i.e. “myplc”), so it looks like this in the file:

192.168.0.1 myplc

Save the file and now if you open a console window and ping myplc the system will attempt to ping 192.168.0.1.

Using the Hostname

Configure the device server or database connection manager in MIStudio using a hostname so that the connection can be made to the device if the IP address is not known or might change at the deployment site. This allows more flexibility so that the project does not need to be opened in MIStudio to change the IP Address of the device connection and rebuilt for deployment for every distribution site.

  • hostnames.txt
  • Last modified: 2020/05/12 19:17
  • by wikiadmin