# getGatewayAddress() in the gateway scope?

**URL:** <https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [July 2, 2019, 11:55am UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218 "2019-07-02T11:55:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 2, 2019, 11:55am UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/1 "2019-07-02T11:55:36Z")

</div>

The **system.util.getGatewayAddress()** is only available in the client scope.  
I would like to obtain the gatewayAddress in the **gateway scope**?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 2, 2019, 12:50pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/2 "2019-07-02T12:50:45Z")

</div>

Which one should it return? There’s at least two, counting localhost. Could be many more. From a client, there’s only the one it actually reached, so it is unambiguous. The best you can do is enumerate your local addresses using Java’s NetworkInterface class.

Unless you are a module developer working on RPC – that has access to the client session within gateway scope.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 2, 2019, 12:54pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/3 "2019-07-02T12:54:27Z")

</div>

my need is to execute a traits in gateway scope only is the gateway has a particular ip.  
A gateway backup can be restored on multiple pc on our network, and I want some traits only execute on the main server.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 2, 2019, 12:56pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/4 "2019-07-02T12:56:02Z")

</div>

Then java’s NetworkInterface class is your friend. Loop through your network interfaces checking each one’s list of addresses.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 2, 2019, 12:57pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/5 "2019-07-02T12:57:44Z")

</div>

Thanks a lot

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 2, 2019, 12:58pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/6 "2019-07-02T12:58:16Z")

</div>

An example you can steal from: [https://github.com/eclipse/milo/blob/master/opc-ua-sdk/sdk-server/src/main/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtil.java](https://github.com/eclipse/milo/blob/master/opc-ua-sdk/sdk-server/src/main/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtil.java)

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 2, 2019, 12:59pm UTC](https://forum.inductiveautomation.com/t/getgatewayaddress-in-the-gateway-scope/26218/7 "2019-07-02T12:59:43Z")

</div>

👍
