Skip to main content
Question

IP Geo-Location Blocked

  • May 23, 2022
  • 5 replies
  • 47 views

DMH2000
Forum|alt.badge.img+7

I have been using an Extension for IP Geo-Location for the past 2 years with no issues.  It was easy to see where the user was located according to the ISP IP address.  

myIP=`curl -L -s --max-time 10 http://checkip.dyndns.org | egrep -o -m 1 '([[:digit:]]{1,3}\\.){3}[[:digit:]]{1,3}'`
myLocationInfo=`curl -L -s --max-time 10 http://ip-api.com/csv/?fields=country,city,region,lat,lon,isp,/$myIP`
echo "<result>$myLocationInfo</result>"

Now I get this on just one computer when I search for All computers. Is there a way to make an exception for an Extension for a computer, or some other method?  It seems like the person's router is blocking the request. It creates this large block of text, which is a pain to look at when searching for All Computers...

<!DOCTYPE html>
<html>
<head>
<title>SHP Redirector</title>
<meta charset="UTF-8">
<meta name="description" content="SHP Redirector">
<link rel="stylesheet" href="/blockpage/css/spinner.min.css?v=3.25.1">
<script src="/blockpage/third-party/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="http://shgw.router:8080/ids.js"></script>
<script src="/blockpage/js/redirector1.3.js?v=3.25.1"></script>
</head>
<body>
<div id="settings" client-domain="http://de8200cd10ad3829fd17f0909d16874e1651757557.f77893c2122400359531656217de21f9.blockpg.shp.safezone.mcafee.com/css/pg.css" ctxt="Kzd5WVBCL0JWS0lTS0c0YWo4Z1RWQndNbUtNWGdUZ0UzVGs0M3cvaHIzTjVVRUJmZE5uWVdCejJJeTl0U20xaUZQN09SNE82QlpzMTFCajJSOFBmbEtYQVZYVit6dlZlMlM5c1RDWlJheWh2MWNRV2xBWmM1eXZNYUpWMGdVZGtjZUdxbWgzS0JEaGZhL1MzSVgyYW5LaVc=" server="https://blockpg-aloe.safezone.mcafee.com" epoch="1651757557" />
<div class="outer">
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
</div>
</body>
</html>

5 replies

pete_c
Forum|alt.badge.img+16
  • Honored Contributor
  • May 23, 2022

Unfortunately, EAs are all or nothing - it'd be amazing if we could scope them, but I doubt that would ever happen.

It would also be nice if the JSS interface was intelligent enough to collapse a table cell when it exceeded a certain size, but again, unlikely to see anytime soon.

So instead you might want to use an if statement to check for the presence of a <!DOCTYPE html> string in $myLocationInfo and then return something like <result>N/A</result>.

 


pete_c
Forum|alt.badge.img+16
  • Honored Contributor
  • May 23, 2022

Unfortunately, EAs are all or nothing - it'd be amazing if we could scope them, but I doubt that would ever happen.

It would also be nice if the JSS interface was intelligent enough to collapse a table cell when it exceeded a certain size, but again, unlikely to see anytime soon.

So instead you might want to use an if statement to check for the presence of a <!DOCTYPE html> string in $myLocationInfo and then return something like <result>N/A</result>.

 


The last time anyone asked me for geolocation in an EA, I used the following:

 

city=$(/usr/bin/curl ipinfo.io -s | awk '/"city": / { print $NF }' | tr -d ' ",')
region=$(/usr/bin/curl ipinfo.io -s | awk '/"region": / { print $NF }' | tr -d ' ",')
country=$(/usr/bin/curl ipinfo.io -s | awk '/"country": / { print $NF }' | tr -d ' ",')

 


DMH2000
Forum|alt.badge.img+7
  • Author
  • Valued Contributor
  • May 23, 2022

@pete_c  Thanks for the info and the suggestion.. something to work on when I'm not busy!

Hope Jamf is listening:  Wish JSS interface was intelligent enough to collapse a table cell when it exceeded a certain size.


pete_c
Forum|alt.badge.img+16
  • Honored Contributor
  • May 23, 2022

The last time anyone asked me for geolocation in an EA, I used the following:

 

city=$(/usr/bin/curl ipinfo.io -s | awk '/"city": / { print $NF }' | tr -d ' ",')
region=$(/usr/bin/curl ipinfo.io -s | awk '/"region": / { print $NF }' | tr -d ' ",')
country=$(/usr/bin/curl ipinfo.io -s | awk '/"country": / { print $NF }' | tr -d ' ",')

 


It was also just pointed out to me that IPInfo.io has flags available in their requests: curl ipinfo.io/country, /city, /ip etc.


Forum|alt.badge.img+11
  • Valued Contributor
  • May 23, 2022

 

I edited the built-in EA to use ifconfig.me instead of checkip.dydns.org.  It's been working so far.

#!/bin/sh

myIP=`/usr/bin/curl http://ifconfig.me/ip`
myLocationInfo=`/usr/bin/curl http://ip-api.com/xml/$myIP`

mycountryCode=`echo $myLocationInfo|egrep -o '<countryCode>.*</countryCode>'| sed -e 's/^.*<countryCode/<countryCode/' | cut -f2 -d'>'| cut -f1 -d'<'`
mycity=`echo $myLocationInfo|egrep -o '<city>.*</city>'| sed -e 's/^.*<city/<city/' | cut -f2 -d'>'| cut -f1 -d'<'`
myregionName=`echo $myLocationInfo|egrep -o '<regionName>.*</regionName>'| sed -e 's/^.*<regionName/<regionName/' | cut -f2 -d'>'| cut -f1 -d'<'`

echo "<result>$mycity, $myregionName - $mycountryCode</result>"