Skip to main content
Solved

Retrieve external IP address in extension attribute


Forum|alt.badge.img+12
  • Valued Contributor
  • 190 replies

Hi all

Can anyone advise me how to create an extension attribute that will record the result of the command curl ifconfig.me

Many thanks
Andy

Best answer by davidacland

You need to set it to be script populated and use:

result=$(curl ifconfig.me)
echo "<result>$result</result>"

I thought the public IP address was in the inventory anyway?

View original
Did this topic help you find an answer to your question?

7 replies

davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • Answer
  • April 10, 2015

You need to set it to be script populated and use:

result=$(curl ifconfig.me)
echo "<result>$result</result>"

I thought the public IP address was in the inventory anyway?


kitzy
Forum|alt.badge.img+14
  • Valued Contributor
  • 167 replies
  • April 10, 2015

Hi @May,

Give this a try.

#!/bin/sh
externalIP=$(curl ifconfig.me)
echo "<result>$externalIP</result>"
exit 0

EDIT: @davidacland beat me to it!


Forum|alt.badge.img+12
  • Author
  • Valued Contributor
  • 190 replies
  • April 10, 2015

@davidacland @kitzy

The inventory only shows the Macs ip address and the IP address of our firewall (when the machine is outside our network)

Thank you!
Andy


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • April 10, 2015

@May I think there's a way to set up the JSS to report the actual external IP address of the client, and not the firewall by adjusting something on the JSS, but it escapes me now. Been a long time since I did it or learned about it now.
Because the JSS should be reporting this natively if set up correctly, which would mean an EA for this isn't necessary. That site for me is horribly slow. It can take upwards of 10-12 seconds for a response to come back even from curl. It might just be our company network though.


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • April 10, 2015

It should be in the tomcat settings:

Enable Remote IP Valve
Ensure that the JSS resolves originating IP addresses instead of apparent client IP addresses when behind a load balancer


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • April 10, 2015

@davidacland Thanks, that's what I was thinking of. Yes, if that's enabled, the IP address should get resolved from the client and not the load balancer.


Forum|alt.badge.img+12
  • Author
  • Valued Contributor
  • 190 replies
  • April 10, 2015

Thanks @davidacland @mm2270

I'll give this a whirl and report back

Cheers again!
Andy


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings