Home Uncategorized How to Check Linux Server Geographic Location

How to Check Linux Server Geographic Location

Sometimes, you might want to retrieve the geographical location of a Linux server due to a wide range of reasons. These include conducting cybercrime forensics or simply out of curiosity.

There are a couple of tools and APIs that you can use to get geographical information about Linux servers such as the IP address, country, and other details. In this guide, we will explore how to find the geolocation of the IP address of a Linux system.

Find Geolocation Using IPinfo

IPInfo is an IP address geolocation lookup that provides a wealth of information about the server’s current geographical information that includes public IP address, City, region country, and timezone.

Find Linux Server Geographic Location

A few prerequisites are required before using the IPInfo lookup tool. You need to install curl and jq command line tools to process data in JSON format from geolocation APIs.

$ sudo apt install jq curl         [On Debian, Ubuntu and Mint]
$ sudo yum install jq curl         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a jq curl           [On Gentoo Linux]
$ sudo apk add jq curl             [On Alpine Linux]
$ sudo pacman -S jq curl           [On Arch Linux]
$ sudo zypper install jq curl      [On OpenSUSE]    

Once installed, you can now query your server’s geolocation details by making a curl request to the geolocation API as shown.

$ curl https://ipinfo.io/json

You will get the following output in JSON format.

Find Linux Server Geolocation
Find Linux Server Geolocation

Find IP Address Geographic Location Using GeoIP Tool

To retrieve information about the country in which the Linux server is hosted, use the GeoIP lookup tool which can be executed on the command line.

But first, you need to install the tool on your Linux system.

$ sudo apt install geoip-bin     [On Debian, Ubuntu and Mint]
$ sudo yum install geoip         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a geoip           [On Gentoo Linux]
$ sudo apk add geoip             [On Alpine Linux]
$ sudo pacman -S geoip           [On Arch Linux]
$ sudo zypper install geoip      [On OpenSUSE]    

Once installed, you can obtain the country information where the server is hosted as shown.

$ geoiplookup ip-address
Find IP Address Geo Location
Find IP Address Geo Location

Find Linux Server IP Address

The IPInfo tool can also return the public IP address only of the server using the following syntax.

$ curl https://ipinfo.io/ip
Find Linux Server IP Address
Find Linux Server IP Address

Additionally, using the cURL command, you can retrieve the public IP address of your Linux server as shown.

$ curl ifconfig.co
$ curl ifconfig.me 
$ curl icanhazip.com
Conclusion

In this article, we have covered some of the ways that you can use to find the geolocation of an IP address and additional information about a Linux server with regard to its location. As always, we cherish your feedback.

Winnie Ondara
My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.