tlhackque / BlockCountries

iptables manager for IP blocking by country
Other
32 stars 6 forks source link

Problem starting on Ubuntu Server #13

Closed eXcalibre closed 8 years ago

eXcalibre commented 8 years ago

I have been using BlockCountries for a while and have just tried to update to 2.21

when i try to load the default config, i get the following error.

root@NS12:~/BlockCountries-2.21-Release# /etc/init.d/BlockCountries -start -update
Unrecognized country/country code: use
root@NS12:~/BlockCountries-2.21-Release# 

This is the ISO part of the config, but its the default in the conf that came with the download.


# List of country codes blocked by default - specify yours in the config file

my @DEFAULT_ISO = qw /cn kr kp kz ru/;
tlhackque commented 8 years ago

Nice to hear that BlockCountries has been helping you.

Thanks for bringing this to my attention.

That message is because you're executing the BlockCountries script from the release directory, but the script is not marked executable. The script is being processed as a configuration file. Change your working directory to someplace else or chmod +x the copy in the release directory, and it will work as expected.

The configuration file search path is listed by the help command, currently:

  1. The the file specified by the environment variable BlockCountriesCFG
  2. ./BlockCountries
  3. ~/BlockCountries
  4. /etc/sysconfig/BlockCountries
  5. /etc/default/BlockCountries
  6. /etc/BlockCountries

This is so that the config file can be found on any UNIXish OS. Unfortunately, the convention is that the config file and the script have the same name.

To avoid most instances of this error, the search ignores any BlockCountries that is executable. But that doesn't work from the release directory due to a packaging error.

You need to be sure that the script itself is marked executable and that your config file is not. You should place your config file in the location that your distribution uses.

I'll change the packaging so that the script is marked executable in the .tar file.

eXcalibre commented 8 years ago

Ok all good and thanks for the speedy reply tlhackque.

One thing to note from the info on the main git site page though, again not sure if its only my distro.

Run

BlockCountries -start -update The filter should download the latest IP country assignments and be in place.

but you state BlockCountries -start -update. the -start does not work, and needs the hyphen removing i.e "BlockCountries start -update" instead.

thank you so much for a really really great little package. :) 👍

root@NS12:~# /etc/init.d/BlockCountries -start -update Usage: BlockCountries (start|stop|restart|condrestart|status|list|intercepts|config|help|version) root@NS12:~# /etc/init.d/BlockCountries start -update Starting blocked countries IP filter: Updated IP zone data from lacnic Updated IP zone data from ripe Updated IP zone data from arin Updated IP zone data from afrinic Updated IP zone data from apnic [ OK ] root@NS12:~#

tlhackque commented 8 years ago

You're right, that's a typo in the documentation that no one else noticed. The first word is always a command, never a switch.

Fixed now.

Permissions are also fixed in git and .tar.gz files. Of course, .zip doesn't store permissions, so anyone who downloads .zip files has to chmod manually.

tlhackque commented 8 years ago

In the next release, the case where BlockCountries attempts to read itself as a configuration file will be detected.

A suitable diagnostic message will be delivered.

The obsolete default configuration will also be removed, and BlockCountries will refuse to start unless a configuration is specified. You should never have a reason to edit the BlockCountries script.

The sample configuration file has been updated - it was never intended to recommend any particular set of countries. The old example is wrong for almost everyone.

BlockCountries will attempt to ensure that the sample configuration file has been reviewed and modified.