OPNsense Forum

Archive => 17.7 Legacy Series => Topic started by: rajl on January 26, 2018, 03:08:15 pm

Title: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: rajl on January 26, 2018, 03:08:15 pm
This is one of those "I followed the documentation, why doesn't it work" questions.

My problem is that when I enable per-country rules for GeoIP blocking, OPNSense blocks all internet traffic instead of just traffic to the prohibited country.  As a test, I created a rule that blocked all outbound traffic to Russia.  I enabled the rule, I enabled Intrusion Detection, and I enabled IPS mode (all per documentation).  I also double-checked to make sure the rule is on the WAN interface only.  With this rule enabled, the expected behavior is that traffic to Russia is blocked, but traffic anywhere else is permitted.  For example, I should be blocked from accessing www.yandex.ru, but allowed to view www.cnn.com or news.bbc.co.uk.  Instead, all outbound traffic is blocked with this single GeoIP rule enabled.

What am I doing wrong?

Thanks.
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: mimugmail on January 26, 2018, 03:48:57 pm
Do you try with IPS or Alias?

Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: rajl on January 26, 2018, 03:58:56 pm
I tried with IPS following the steps straight from the documentation.
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: mimugmail on January 26, 2018, 10:11:31 pm
Doc is a bit outdated, try with Geo IP alias in Firewall aliases
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: rajl on January 27, 2018, 04:24:07 am
Thanks.

Unfortunately, my country (United States) is missing.  Every other country in the Americas is listed, including the U.S. Virgin Islands.  However, the U.S. itself is missing from the list of countries in the Americas. ::)
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: mimugmail on January 27, 2018, 08:52:03 am
Pacific - United States .. at the bottom
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: franco on January 27, 2018, 01:59:02 pm
Those fancy countries with their spanning multiple regions...

https://github.com/opnsense/core/commit/7ebd5fcd


Cheers,
Franco
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: rajl on January 27, 2018, 10:19:01 pm
Those fancy countries with their spanning multiple regions...

https://github.com/opnsense/core/commit/7ebd5fcd


Cheers,
Franco

Yeah, when you don’t follow the ISO assignment (https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_(data_file)) for countries to continents, you get some dumb questions like mine. :). You also end up with Russia in Asia and Turkey in Europe (to name a few other odd balls I saw).

EDIT: Correct iPhone Typos
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: franco on January 28, 2018, 12:53:16 pm
We cannot precisely follow ISO 3166 because the most prevalent provider of the codes which is tzdata does not include the Continent Code:

https://github.com/opnsense/core/blob/master/contrib/tzdata/iso3166.tab

So we extrapolate from the zone mapping...

https://github.com/opnsense/core/blob/master/contrib/tzdata/zone.tab

... and that is ambiguous because it maps time zones, not countries.


Cheers,
Franco
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: dcol on January 28, 2018, 09:51:33 pm
I do a two tier approach. Weeding out the top 10 worst spam countries with IPS, then the rest with GeoIP.
That way IPS can drop the highest traffic offenders before my firewall has to deal with it.
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: marjohn56 on January 28, 2018, 11:36:01 pm
I use Spam Hero to handle all my inbound, takes the strain off my system, all the mx records point to them and they are not expensive. I use Geo Blocker for almost all countries except the ones I travel to most or need to have open. I've just found a quite useful list I've added as an alias, which is working well. it's in a straight text format so dead easy to import.

http://bl.plonkatronix.com/plonkatronixRBL.txt (http://bl.plonkatronix.com/plonkatronixRBL.txt)

Certainly stopped the 'plonker' who kept trying to get into my server.
Title: Re: GeoIP Blocks All Traffic Instead of Per-Country Traffic
Post by: rajl on January 30, 2018, 05:19:07 pm
We cannot precisely follow ISO 3166 because the most prevalent provider of the codes which is tzdata does not include the Continent Code:

https://github.com/opnsense/core/blob/master/contrib/tzdata/iso3166.tab

So we extrapolate from the zone mapping...

https://github.com/opnsense/core/blob/master/contrib/tzdata/zone.tab

... and that is ambiguous because it maps time zones, not countries.


Cheers,
Franco

 ::) Leave it to ISO to create a standard that no one can follow.

Appreciate the technical explanation.  It makes sense.