< All Topics
Print

How to Install GeoIP on AlmaLinux 9 or Rocky Linux 9

Why You Should Install GeoIP on AlmaLinux 9 or Rocky Linux 9

GeoIP is a vital tool for enhancing the functionality and security of your web services on AlmaLinux 9 or Rocky Linux 9. Here are compelling reasons to install it:

  • Enhanced Website Personalization : GeoIP enables you to identify the geographical location of your visitors, allowing you to personalize their experience. By tailoring content and services based on the user’s location, you can significantly improve user engagement and satisfaction.
  • Optimized Content Delivery : With GeoIP, you can deliver content from servers closest to your users, thereby reducing latency and enhancing website performance. This is particularly beneficial for global websites aiming to provide a seamless experience to users worldwide.
  • Improved Security Measures : GeoIP aids in filtering traffic based on geographic locations. This can help mitigate security risks by blocking or monitoring traffic from regions known for high levels of cyber threats, thus enhancing your website’s security posture.
  • Compliance with Regulations : Utilizing GeoIP can assist in adhering to various regional data protection laws, such as GDPR. It enables you to manage data handling practices in compliance with local regulations, ensuring that you meet legal requirements across different jurisdictions.
  • Valuable Analytics and Insights : GeoIP provides critical data about the geographical distribution of your audience. This information can be leveraged to refine marketing strategies, optimize content for specific regions, and make informed business decisions based on user behavior patterns.
  • Localization and Geotargeting : By identifying the precise location of your users, GeoIP facilitates the localization of content and enables targeted marketing campaigns. This capability is crucial for businesses looking to expand their reach into new markets or regions.

Installing GeoIP on AlmaLinux 9 or Rocky Linux 9 is straightforward and comes with a wealth of benefits, including detailed location data such as country, region, city, latitude, and longitude. By leveraging this tool, you can unlock powerful location-based insights and elevate your website’s user experience to new heights.

In conclusion, installing GeoIP on your AlmaLinux 9 or Rocky Linux 9 system will not only enhance the security and personalization of your web services but also provide you with the tools needed to grow and adapt your online presence to a global audience effectively.

Install GeoIP Packages on Almalinux 9/ Rocky Linux 9

Update system and install the epel-release before installing the GeoIP

[root@corecloudconnect ~]# sudo dnf install GeoIP
Last metadata expiration check: 0:00:13 ago on Sat 25 Jan 2025 09:33:22 PM CET.
Dependencies resolved.
=============================================================================================================================================================================================================================================
 Package                                                         Architecture                                        Version                                                         Repository                                         Size
=============================================================================================================================================================================================================================================
Installing:
 GeoIP                                                           x86_64                                              1.6.12-9.el9.remi                                               remi                                              115 k
Installing dependencies:
 GeoIP-GeoLite-data                                              noarch                                              2018.06-8.el9.remi                                              remi                                              650 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  2 Packages

Total download size: 765 k
Installed size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): GeoIP-1.6.12-9.el9.remi.x86_64.rpm                                                                                                                                                                    1.2 MB/s | 115 kB     00:00    
(2/2): GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch.rpm                                                                                                                                                      5.0 MB/s | 650 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        4.5 MB/s | 765 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                     1/1 
  Installing       : GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        1/2 
  Installing       : GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      2/2 
  Running scriptlet: GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        2/2 
  Running scriptlet: GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      2/2 
  Verifying        : GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      1/2 
  Verifying        : GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        2/2 

Installed:
  GeoIP-1.6.12-9.el9.remi.x86_64                                                                                 GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                

Complete!
[root@[root@mta910p-border ~]# sudo dnf install GeoIP
Last metadata expiration check: 0:00:13 ago on Sat 25 Jan 2025 09:33:22 PM CET.
Dependencies resolved.
=============================================================================================================================================================================================================================================
 Package                                                         Architecture                                        Version                                                         Repository                                         Size
=============================================================================================================================================================================================================================================
Installing:
 GeoIP                                                           x86_64                                              1.6.12-9.el9.remi                                               remi                                              115 k
Installing dependencies:
 GeoIP-GeoLite-data                                              noarch                                              2018.06-8.el9.remi                                              remi                                              650 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  2 Packages

Total download size: 765 k
Installed size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): GeoIP-1.6.12-9.el9.remi.x86_64.rpm                                                                                                                                                                    1.2 MB/s | 115 kB     00:00    
(2/2): GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch.rpm                                                                                                                                                      5.0 MB/s | 650 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        4.5 MB/s | 765 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                     1/1 
  Installing       : GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        1/2 
  Installing       : GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      2/2 
  Running scriptlet: GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        2/2 
  Running scriptlet: GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      2/2 
  Verifying        : GeoIP-1.6.12-9.el9.remi.x86_64                                                                                                                                                                                      1/2 
  Verifying        : GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                                                                                                        2/2 

Installed:
  GeoIP-1.6.12-9.el9.remi.x86_64                                                                                 GeoIP-GeoLite-data-2018.06-8.el9.remi.noarch                                                                                

Complete!
[root@corecloudconnect ~]#  ~]# 

Check install


GeoIP Update (Optional)

GeoIP Update is available on GitHub and is created by the GeoIP developers to update the GeoIP2 and GeoLite binary databases. To use it, we need to wget the latest RPM binary for Linux distros (all, not only AlmaLinux or Rocky) and install it from their Software GitHub page.

  • Visit the Github page with the latest release of the GeoIPUpdate; here is the link
  • Get the link for the latest RPM version of your Architecure, mostlty this will be AMD64
  • Copy the link to use in the terminal of your target server, right click the file link and select Copy link address
  • install wget on your system
sudo dnf install wget -y

wget past-the-link

Example:

wget https://github.com/maxmind/geoipupdate/releases/download/v7.1.0/geoipupdate_7.1.0_linux_amd64.rpm

Install once download is on your system

sudo rpm -Uvhi geoipupdate_*_linux_amd64.rpm

Once downloaded the latest version, create or login on https://www.maxmind.com/ to obtain a license and the GeoIP.conf file. By default, the geoipupdate uses the /etc/GeoIP.conf file

# GeoIP.conf file for `geoipupdate` program, for versions >= 3.1.1.
# Used to update GeoIP databases from https://www.maxmind.com.
# For more information about this config file, visit the docs at
# https://dev.maxmind.com/geoip/updating-databases.

# `AccountID` is from your MaxMind account.
AccountID 7XXXXX

# Replace YOUR_LICENSE_KEY_HERE with an active license key associated
# with your MaxMind account.
LicenseKey YOUR_LICENSE_KEY_HERE

# `EditionIDs` is from your MaxMind account.
EditionIDs GeoLite2-ASN GeoLite2-City GeoLite2-Country

Our default installation is not up-to-date yet, verify the GeoIP dates of the datasets

[root@corecloudconnect]# cd /usr/share/GeoIP/
[root@corecloudconnect]# ls -lha
total 65M
drwxr-xr-x.   2 root root 4.0K Nov 18 18:54 .
drwxr-xr-x. 162 root root 4.0K Jan 10 10:39 ..
lrwxrwxrwx    1 root root   18 Jan 25 21:39 GeoIP.dat -> GeoLiteCountry.dat
-rw-r--r--.   1 root root  60M Dec 17  2019 GeoLite2-City.mmdb
-rw-r--r--.   1 root root 3.9M Dec 17  2019 GeoLite2-Country.mmdb
-rw-r--r--    1 root root 1.2M Apr  4  2018 GeoLiteCountry.dat

Now with the license file in place, you can run the geoipupdate

[root@corecloudconnect]# geoipupdate -v
geoipupdate version 7.1.0 (662daf83, 2024-11-18T17:41:36Z, linux-amd64)
Using config file /etc/GeoIP.conf
Using database directory /usr/share/GeoIP
Initializing file lock at /usr/share/GeoIP/.geoipupdate.lock
Acquired lock file at /usr/share/GeoIP/.geoipupdate.lock
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-ASN.mmdb: 0d9d6232f16009fb08fb0af780272829
New updates available for GeoLite2-ASN
Database GeoLite2-ASN up to date
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-City.mmdb: 33d723055eb883d6ea90b82422a09eb1
New updates available for GeoLite2-City
Database GeoLite2-City up to date
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-Country.mmdb: ac1a18256a98292497905bba26ab9f2f
New updates available for GeoLite2-Country
Database GeoLite2-Country up to date
Lock file /usr/share/GeoIP/.geoipupdate.lock successfully released

To fully automate this process on Linux or Unix, use a crontab file like: ()

# top of crontab
[email protected]
10 23 * * 1,3 /usr/bin/geoipupdate
# end of crontab

Note: The geoipupdate location is different than the default on the maxmind website!

Now your server has up to date GeoIP data, to use with your Webserver, Websites, FireWall and more.

Table of Contents
Scroll to Top