# Get Gatways "MAC Address,IP Address,Hostname"

**URL:** <https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448>\
**Category:** Help\
**Tags:** edge\
**Created:** [December 6, 2019, 9:46am UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448 "2019-12-06T09:46:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivasankari\_s2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@sivasankari\_s2](https://forums.losant.com/u/sivasankari_s2)\
**Post date:** [December 6, 2019, 9:46am UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448/1 "2019-12-06T09:46:02Z")

</div>

Hi,  
I want to get Gateway’s Mac Address,IP address,Hostname using  
Losant edge work flow.  
I took a look on “agentEnviroment”.  
 ![agentEnvironment](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cac1805226848c29192e405bd9c628d5df1ab18a.jpeg) .  
But the Hostname is some object format.  
How to get the exact Hostname?

Thanks,  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [December 6, 2019, 2:32pm UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448/2 "2019-12-06T14:32:27Z")

</div>

Hi @sivasankari_s2,

Just a couple questions so I can assist further. Are you including the Gateway Hostname as an Environment Variable on container startup? What is the expected format? I believe the `HOSTNAME` included in your screenshot above denotes the Hostname of the container, are you including the Gateway’s as well?

Thanks,  
Julia

---

<div class="post-metadata">

**Author:** ![sivasankari\_s2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@sivasankari\_s2](https://forums.losant.com/u/sivasankari_s2)\
**Post date:** [December 6, 2019, 3:02pm UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448/3 "2019-12-06T15:02:06Z")

</div>

Hi julia,  
Thanks for your reply.  
I got the Container Id as a hostname.But I need a gatway’s name(Computer Name)  
and MAC address ,IPaddress  
Image 1:Container Details

 ![containers](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b5c6756f372558447069192d02fc6c8f8a71014c.jpeg)

Image 2.Gateways IP and MAC Address in commandline

 ![ipadd](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/9/97d5fe815ec6afcfe537d903a1e3f2c56ddde902.jpeg)  
I need get the above marked “MAC Address and Ip Address” using Edge Workflow.

Thanks,  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [December 6, 2019, 4:20pm UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448/5 "2019-12-06T16:20:32Z")

</div>

Hi @sivasankari_s2,

In order to access these variables in an Edge Workflow, they must be included as an Environment Variable on the container startup. In order to obtain the IP address and MAC address, I use commands that are specific to my MacOS operating system. Depending on your operating system, this command will vary. The command `ifconfig en1 | awk '/ether/{print $2}'` returns the MAC address of my device, and I include it as an environment variable on container startup:

 ![Screen Shot 2019-10-17 at 4.30.49 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/a/a4f0ce42aa9fb232307fa8367f0ace8673b76d3a.png)

am running with a config file, but am including the `DOCKER_HOST` environment variable:

> docker run -d --restart always --name -e “DOCKER\_HOST=$(ifconfig en1 | awk '/ether/{print $2}’)” -v /var/lib/losant-edge-agent/data:/data -v /var/lib/losant-edge-agent/config.toml:/etc/losant/losant-edge-agent-config.toml losant/edge-agent

Over in my workflow, my debug log shows that my MAC address is included in the payload.

 ![Screen Shot 2019-12-06 at 10.42.58 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/d/da7e37d65bc26d7d00fcf7754b27c1d0de6b00ae.jpeg)

The command to retrieve an IP address on my machine is `ipconfig getifaddr en0` , and just as before, I include this as an environment variable:

 ![Screen Shot 2019-10-17 at 4.52.04 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/5/5ccc093c0020951e96b2d1b70be0eae67f679989.png)

Then, over in my workflow, I can that my IP address is included on the payload:

 ![Screen Shot 2019-10-17 at 4.50.36 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b4106c2f8c301a476ae4d24445457c0ba7c6a1e3.png)

Please let me know if I can explain anything further!

Have a great day,  
Julia

---

<div class="post-metadata">

**Author:** ![sivasankari\_s2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@sivasankari\_s2](https://forums.losant.com/u/sivasankari_s2)\
**Post date:** [December 7, 2019, 4:43am UTC](https://forums.losant.com/t/get-gatways-mac-address-ip-address-hostname/2448/6 "2019-12-07T04:43:14Z")

</div>

> [@JuliaKempf](#):
>
> ifconfig en1 | awk '/ether/{print $2}’

Thanks for your prompt reply.I will try which is you are mentioned.  
Thanks,  
Sivasankari S
