Use another IP locator than ifconfig.me that provides with that information like:
curl -s 'http://geoiplookup.net/geoapi.php?output=countrycode'
or:
curl -s 'http://geoiplookup.net/geoapi.php?output=country'
(see the API for details)
or:
curl -s http://whatismycountry.com/ |
sed -n 's|.*,\(.*\)</h1>|\1|p'
or:
curl -s http://whatismycountry.com/ |
sed -n 's|.*> *\(.*\)</h1>|\1|p'
for more precision, or:
curl -s http://whatismycountry.com/ |
sed -n 's/.*Coordinates \(.*\)<.*/\1/p'
for the coordinates.
That makes assumptions on the HTML formatting of the page. So it may stop working if they decide to change that format in the future.