[SOLVED] GeoIP with MaxMind

Dec 27, 2020
108
16
23
44
I am sure its me, however I cannot seem to get GeoIP working.

I have following this guide which is a variation of Heutgers':
https://github.com/killmasta93/tutorials/wiki/PMG-Harden#geoip
https://forum.proxmox.com/threads/a...y-spam-and-virus-detection.44152/#post-211196

/etc/GeoIP.conf
Code:
AccountID xxx
LicenseKey yyy
EditionIDs GeoLite2-Country

/etc/pmg/templates/init.pre.in
Code:
loadplugin Mail::SpamAssassin::Plugin::RelayCountry

/etc/mail/spamassassin/custom.cf
Code:
ifplugin Mail::SpamAssassin::Plugin::RelayCountry
#    country_db_type (GeoIP|GeoIP2|DB_File)  #Tried all 3 and hashed out!!!
    country_db_path /usr/share/GeoIP/GeoLite2-Country.mmdb

    add_header all Relay-Country _RELAYCOUNTRY_
    header     RELAYCOUNTRY_BAD X-Relay-Countries =~ /(CN|RU)/
    describe   RELAYCOUNTRY_BAD Email Originating from Untrusted Countries
    score      RELAYCOUNTRY_BAD 2.0

    header     RELAYCOUNTRY_GOOD X-Relay-Countries =~ /^(AU|NZ)/
    describe   RELAYCOUNTRY_GOOD Trusted Countries
    score      RELAYCOUNTRY_GOOD -0.5
endif # Mail::SpamAssassin::Plugin::RelayCountry

apply the changes
Code:
pmgconfig sync --restart 1
spamassassin -D --lint
echo "test" | spamassassin -D pyzor 2>&1

It doesnt update:
Code:
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on spam.domain
X-Spam-Flag: YES
X-Spam-Level: ********
X-Spam-Status: Yes, score=8.3 required=5.0 tests=EMPTY_MESSAGE,
        KAM_BLANKSUBJECT,KAM_DMARC_STATUS,MISSING_DATE,MISSING_FROM,
        MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE,
        NO_RECEIVED,NO_RELAYS shortcircuit=no autolearn=no autolearn_force=no
        version=3.4.6
X-Spam-Relay-Country: _RELAYCOUNTRY_

Any assistance would be much appreciated.
 
spamassassin's debug output goes to stderr - try
Code:
spamassassin -D --lint 2> sa.txt
 
Thanks @Stoiko Ivanov

Code:
Feb 28 20:41:44.318 [111474] dbg: metadata: RelayCountry: GeoIP2: /usr/share/GeoIP/GeoLite2-Country.mmdb load failed: Can't locate GeoIP2/Database/Reader.pm in @INC (you may need to install the GeoIP2::Database::Reader module) (@INC contains: lib /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /usr/share/perl5/Mail/SpamAssassin/Plugin/RelayCountry.pm line 284.
Feb 28 20:41:44.318 [111474] dbg: metadata: [...] , trying IP::Country::Fast as fallback

Found the issue - I missed installing the Reader:
Code:
perl -MCPAN -e 'install GeoIP2'
 
I would suggest to rather install the perl-package from the debian repository:
libgeoip2-perl

should ensure that you get any updates and should make upgrades across major version stable

I hope this helps!
 
  • Like
Reactions: karnz and zolthar

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!