Koozali.org: home of the SME Server

Xt GeoIP - BadCountries

Offline gieres

  • *
  • 213
  • +0/-0
Xt GeoIP - BadCountries
« on: September 08, 2023, 03:33:24 PM »
Hi,
SME 10 - Server and gateway
Xt GeoIP installed
BadCountries :
Code: [Select]
config show masq
masq=service
    BadCountries=SG,CN,IN,VN,BR,TW,KR,ID,RU,FI,HK,UA,NG,AR
    DenylogTarget=drop
    GeoIP=enabled
    Logging=most
    Stealth=no
    Trace=disabled
    XTGeoipOther=disabled
    XTGeoipRev=disabled
    XtServices=ftp,imap,imaps,pop3,pop3s,qpsmtpd,sqpsmtpd,sshd,pptpd
    pptp=yes
    status=enabled

In server-manager, in GeoIP panel, in statistics, it's wroten :

Administration XTABLES-ADDONS
GeoIP
Statistiques générées [ ipt ] 2023/09/08 02:05

  Smeserver daily statistics for Xtables - GEOIP
           from kooz2.albe.ovh - 2023-09-07

  Numbers of IPs banned (xt_geoip) by country during LAST DAY
       ( XX means 'country not found' )

--------------------
CN | 5752 | 44.6%
IN | 1515 | 11.8%
RU | 1154 | 9.0%
KR | 1246 | 9.7%
XX | 843 | 6.5%
BR | 453 | 3.5%
VN | 360 | 2.8%
TW | 293 | 2.3%
US | 174 | 1.4%
SG | 125 | 1.0%
NL | 135 | 1.0%
HK | 203 | 1.6%
UA | 71 | 0.6%
SE | 4 | 0.0%
PL | 107 | 0.8%
PA | 1 | 0.0%
NG | 13 | 0.1%
LU | 4 | 0.0%
KH | 1 | 0.0%
JP | 76 | 0.6%
IL | 4 | 0.0%
ID | 107 | 0.8%
GB | 32 | 0.2%
FR | 17 | 0.1%
FI | 18 | 0.1%
DE | 24 | 0.2%
CY | 4 | 0.0%
CR | 3 | 0.0%
CO | 26 | 0.2%
CA | 6 | 0.0%
BO | 2 | 0.0%
AU | 2 | 0.0%
AT | 4 | 0.0%
AR | 106 | 0.8%
--------------------
   | 12885 | 100%
--------------------

Why so many IPs (and SPECIALLY so many countries) banned by Xt GeoIP while BadCountries contains only 14 countries ?

Thanks in advance.
« Last Edit: September 12, 2023, 07:42:00 PM by gieres »

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #1 on: September 08, 2023, 05:19:33 PM »
Have you got any 'per service' filters set?

eg you may have generic ones in

Code: [Select]
config show masq

But others in:

Code: [Select]
config show qpsmtpd
Check all your services for 'BadCountries'

Code: [Select]
config show |grep BadCountries
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,767
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Xt GeoIP - BadCountries
« Reply #2 on: September 11, 2023, 07:16:22 PM »
Code: [Select]
config getprop sshd BadCountries

Offline gieres

  • *
  • 213
  • +0/-0
Re: Xt GeoIP - BadCountries
« Reply #3 on: September 12, 2023, 07:56:41 PM »
Have you got any 'per service' filters set?

No.

Code: [Select]
config show |grep BadCountries
    BadCountries=SG,CN,IN,VN,BR,TW,KR,ID,RU,FI,HK,UA,NG,AR

Code: [Select]
config getprop sshd BadCountries
[root@sme ~]#config getprop sshd BadCountries
[root@sme ~]#
Nothing.

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #4 on: October 05, 2023, 11:43:03 PM »
Quote
Why so many IPs (and SPECIALLY so many countries) banned by Xt GeoIP while BadCountries contains only 14 countries

As a thought - this may be down to the mailstats reporting contrib by Brian?

Might need a bug.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline brianr

  • *
  • 988
  • +2/-0
Re: Xt GeoIP - BadCountries
« Reply #5 on: October 06, 2023, 09:46:58 AM »
As a thought - this may be down to the mailstats reporting contrib by Brian?

Might need a bug.

That table of percentage versus Country code is not from mailstats, the mailstats table shows the country for each of ALL emails for the interval and shows an asterisk if that country appears in the banned list:

Code: [Select]
Geoip results: (cutoff at 0.5%)
---------------------------------------------
Country Percent Count Rejected?
---------------------------------------------
US 88.8% 1129
DE 3.5% 44
GB 2.8% 35
NL 2.4% 31
CH 1.6% 20 *
---------------------------------------------
TOTALS 100.0% 1272
---------------------------------------------

Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #6 on: October 06, 2023, 09:54:04 AM »
Ok thanks Brian.

I'll try and take a peek at how this is calculated.

The person who really knows is mab. I'll try & ping them too.

May need a bug.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #7 on: October 06, 2023, 04:27:57 PM »
So the answers will lie buried in the smeserver-xt_geoip contrib.

First check what the crontab does

Code: [Select]
cat /etc/crontab |grep geoip
Something like this:

Code: [Select]
#       saturday at 06:00 update xtables geoip base
00 06 * * 6 root /usr/share/xt_geoip/update_base >/dev/null
45 1 * * * root /usr/share/xt_geoip/geoip_stats f2b >/dev/null
50 1 * * * root /usr/share/xt_geoip/geoip_stats ssh >/dev/null
55 1 * * * root /usr/share/xt_geoip/geoip_stats ipt >/dev/null
05 2 * * * root /usr/share/xt_geoip/geoip_listat >/dev/null

That wil llead you to

Quote
/usr/share/xt_geoip/geoip_stats

Note that it will count entries from Fail2Ban if you have it enabled.

You can also look at generateStats in

Code: [Select]
/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm
That shows you how it reads the generated files for display.

Beyond that we need mab to advise!

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline gieres

  • *
  • 213
  • +0/-0
Re: Xt GeoIP - BadCountries
« Reply #8 on: October 07, 2023, 08:19:29 PM »

Code: [Select]
# cat /etc/crontab |grep geoip
Code: [Select]
#       saturday at 06:00 update xtables geoip base
00 06 * * 6 root /usr/share/xt_geoip/update_base >/dev/null
45 1 * * * root /usr/share/xt_geoip/geoip_stats f2b >/dev/null
50 1 * * * root /usr/share/xt_geoip/geoip_stats ssh >/dev/null
55 1 * * * root /usr/share/xt_geoip/geoip_stats ipt >/dev/null
05 2 * * * root /usr/share/xt_geoip/geoip_listat >/dev/null

As you.

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #9 on: October 07, 2023, 08:26:16 PM »
That is just to help you undestand how it works :-)

Do you have fail2ban installed as well?
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline gieres

  • *
  • 213
  • +0/-0
Re: Xt GeoIP - BadCountries
« Reply #10 on: October 14, 2023, 07:33:43 PM »
Hi,
Thanks for details but it's too hard for me.
Yes, fail2ban is installed :
Code: [Select]
# config show fail2ban
fail2ban=service
    BanTime=2592000
    FindTime=300
    Mail=enabled
    status=enabled

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Xt GeoIP - BadCountries
« Reply #11 on: October 25, 2023, 01:11:02 PM »
Yes, fail2ban is installed :

See my comment above:

Quote
Note that it will count entries from Fail2Ban if you have it enabled.

Thanks for details but it's too hard for me.

What makes you think it is easy for me?

I just sit patiently and read things. After 40 years i understand a little more.

You just have to roll up your sleeves and start learning.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation