Getting IP address of device


#1

In the summary section of the resin console of each device, you can see that it tells you what the IP ADDRESS is of the current device. Is there an easy way to get this number in a service / host os?

My goal is to record this in an environment variable locally on boot so that my application’s know what the IP address is.


#4

Hey @bgold, you can do this using the Supervisor API from within one of your containers:

curl -X GET --header "Content-Type:application/json" \ "$RESIN_SUPERVISOR_ADDRESS/v1/device?apikey=$RESIN_SUPERVISOR_API_KEY"

This will give you the IP amongst other things; take a look here: https://docs.resin.io/reference/supervisor/supervisor-api/
Note if you’re running multicontainer you need to enable it: https://docs.resin.io/learn/develop/multicontainer/#labels

Hope this helps!


#5

Awesome, thank you sir. This will do.

Would be amazing to see this end up in the RESIN_ Environment Variables at some point. Seem’s useful enough but what do I know haha