GeoIP mit MaxMind und RelayCountry Plugin

proxminent

Well-Known Member
Jan 15, 2019
71
15
48
47
Stuttgart, Germany
Hallo an die Runde,

Analog zu diesen Post. https://forum.proxmox.com/threads/geoip-with-maxmind.105656/
versuche ich gerade der RelayCountryPlugin einzurichten ...

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

/etc/mail/spamassassin/custom.cf
Code:
#geodb_module DB_File
#geodb_options country:/var/lib/GeoIP/ipcc.db

ifplugin Mail::SpamAssassin::Plugin::RelayCountry

    geodb_module GeoIP2
    geodb_search_path /var/lib/GeoIP/

    header          RELAYCOUNTRY_BAD X-Relay-Countries =~ /^(AR|CN|BR|IN|VN|RU)/
    describe        RELAYCOUNTRY_BAD First untrusted relay is Argentina, China, Brazil, India, Vietnam or Russia
    score           RELAYCOUNTRY_BAD 1.5

    header          RELAYCOUNTRY_SUSP X-Relay-Countries =~ /^(UA|BY|LT|EE|HU|RO|NL)/
    describe        RELAYCOUNTRY_SUSP First untrusted relay is Ukraine, Belarus, Lithuania, Estonia, Hungary, Romania, Nederland
    score           RELAYCOUNTRY_SUSP 0.5

    header          RELAYCOUNTRY_GOOD X-Relay-Countries =~ /^(EU|DE)/
    describe        RELAYCOUNTRY_GOOD First untrusted relay is Deuschland or European Union :-)
    score           RELAYCOUNTRY_GOOD -0.2


    add_header all Relay-Country _RELAYCOUNTRY_

endif # Mail::SpamAssassin::Plugin::RelayCountry


Code:
pmgconfig sync --restart 1
spamassassin -D --lint


spamassassin --lint -D 2>&1|grep -i country
Code:
Apr 30 17:00:18.798 [6921] dbg: diag: [...] optional module installed: IP::Country::DB_File, version 3.03
Apr 30 17:00:18.798 [6921] dbg: diag: [...] optional module installed: IP::Country::Fast, version 604.001
Apr 30 17:00:18.805 [6921] dbg: plugin: loading Mail::SpamAssassin::Plugin::RelayCountry from @INC
Apr 30 17:00:21.617 [6921] dbg: plugin: Mail::SpamAssassin::Plugin::RelayCountry=HASH(0x55d96e5eef48) implements 'extract_metadata', priority 0
Apr 30 17:00:21.617 [6921] dbg: metadata: X-Relay-Countries:
Apr 30 17:00:21.617 [6921] dbg: check: tagrun - tag RELAYCOUNTRY is now ready, value: ARY:[]
Apr 30 17:00:21.617 [6921] dbg: metadata: X-Relay-Countries-External:
Apr 30 17:00:21.618 [6921] dbg: check: tagrun - tag RELAYCOUNTRYEXT is now ready, value: ARY:[]
Apr 30 17:00:21.618 [6921] dbg: metadata: X-Relay-Countries-Auth:
Apr 30 17:00:21.618 [6921] dbg: check: tagrun - tag RELAYCOUNTRYAUTH is now ready, value: ARY:[]
Apr 30 17:00:21.618 [6921] dbg: metadata: X-Relay-Countries-All:
Apr 30 17:00:21.618 [6921] dbg: check: tagrun - tag RELAYCOUNTRYALL is now ready, value: ARY:[]

spamassassin --lint -D 2>&1|grep -i geo
Apr 30 17:02:45.495 [7454] dbg: diag: [...] optional module installed: Geo::IP, version 1.51 Apr 30 17:02:47.371 [7454] dbg: config: no description set for rule GEO_QUERY_STRING Apr 30 17:02:47.437 [7454] dbg: rules: meta test KAM_IMAGEONLY has undefined dependency 'PDS_OTHER_BAD_TLD' Apr 30 17:02:48.316 [7454] dbg: geodb: GeoIP2: search found city /var/lib/GeoIP//GeoLite2-City.mmdb Apr 30 17:02:48.321 [7454] dbg: geodb: GeoIP2: loaded city from /var/lib/GeoIP//GeoLite2-City.mmdb Apr 30 17:02:48.325 [7454] dbg: geodb: database info: GeoIP2 city: GeoLite2 City database / Thu Apr 27 16:45:52 2023


aber ...
sonst sehe ich auf die gefilterten Mail keinen Hinweis dass RelayCountry läuft ...
Irgendeine Idee ?
Tips ?
Vielen Dank
 
Hallo proxminent,

ich stehe momentan vor dem gleichen Problem. Ich bin während meiner Recherche über diesen Blog gestolpert. Er sagt aus, dass Amavis mindestens diesen Relay-Country-Header entfernt. Daher bin ich jetzt auf der Suche, ob bei Proxmox ebenfalls ein Dienst in der Pipe Header löscht...

Edit:
Ich möchte hinzufügen, dass die Auswertung scheinbar funktioniert.
Bash:
spamassassin -D < testmail.eml 2>&1 | grep -i 'X-Relay-Countries'
gibt folgendes aus:
Bash:
Jun 20 15:54:06.262 [17632] dbg: metadata: X-Relay-Countries: DE **
Jun 20 15:54:06.262 [17632] dbg: metadata: X-Relay-Countries-External: DE **
Jun 20 15:54:06.262 [17632] dbg: metadata: X-Relay-Countries-Auth:
Jun 20 15:54:06.262 [17632] dbg: metadata: X-Relay-Countries-All: ** DE **

Wäre dennoch super, diese Header auch in der Mail zu haben. Möglicherweise hat jemand einen Hinweis?
 
Last edited:
Der Header X-Spam-Level ist vorhanden und wird per Regel eingefügt wenn ich das grade richtig im Kopf habe.
Das nutzen dieser "Macros" wird im AdminGuide aufgezeigt. Möglicherweise muss angepasst werden welche Header die Variable __SPAM_INFO__ in den Header der Mail übernimmt?
 
Ich habe weitere Erkenntnisse. In der Mail.log ist der folgende Eintrag aufgetaucht:
Code:
Jun 22 13:46:17 mx pmg-smtp-filter[2281]: WARNING: geodb: IP::Country::DB_File country load failed: Can't open database /usr/local/share/ip-country-dbfile/ipcc.db
Da die Datenbank aber für jeden auf dem System lesbar war, habe ich testweise auf die Maxmind GeoIp2Lite umgestellt.
Anschließend enthält der X-SPAM-LEVEL Header die Info
Code:
RELAYCOUNTRY_GOOD -0.5 First untrusted GW DE, AT or CH
Warum die ipcc.db nicht vom pmg-smtp-filter lesbar ist, versuche ich noch herauszufinden...
 

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!