Gateway address (route) for a network and DNS server address are different things. And both are different from the return value of system.util.getGatewayAddress().
The latter is used from a Vision client to know where to contact the gateway if an out-of-band connection is needed.
For the “default gateway” network route, java doesn’t actually expose it in any standard way. The best you can do is identity the network interface that would be used to hit the default gateway (by connecting a UDP socket to some arbitrary but routable external address).
Java also does not expose any information about DNS, but will look up names for you. See the java.net package.
Assuming you’re calling this from Vision client scope, you can ‘shortcut’ that system utils call via:
var connection = com.inductiveautomation.ignition.client.gateway_interface.GatewayConnectionManager#getInstance();
var httpUrl = connection.getGatewayAddress();
where httpUrl will be a com.inductiveautomation.ignition.common.gateway.HttpURL you can examine for different information. ClientSystemUtilities does the same thing, but toString()s the result.
I think you’ll have to introduce your own abstraction here. For Vision or the designer, the ‘gateway address’ is, by definition, the address that the local JVM is receiving communications from, so it’s known. Similarly for Perspective, which is what we put into the session property. For general gateway use, you’re going to have a hard time; there’s no communication channel to check. You could check for a specific named NetworkInterface, if you’re able to make guarantees about where your module will be installed.
Yes, but if you're planning to read [System]Client/Network/GatewayAddress, that won't do any good. That tag only exists in the client & designer scope, where it will just return the same result as the code I posted further up stream.
For programatically reading a tag, see this thread, except instead of browseAsync you'll be calling readAsync:
@PGriffith because our gateway VM’s always have a certain address format we think we can use the following and pass the return into our function as an additional parameter.
As far as we can tell it will work because we invoke the script from the attribute mapping on the IDP using “runScript” and because it will then run in the gateway context, it will give us the gateway hostname that is not modifiable hence a reliable source of the site number.