Though Ubuntu Linux offers packages for GeoIP filtering, with version 12.10 GeoIP filtering doesn't work anymore. Ubuntu decided to stay at version 1.42 of xtables which is incompatible with kernel 3.5. Kernel 3.5 is the standard in Ubuntu 12.10. The only fast way to overcome this issue was to upgrade to the latest version of xtables - 1.47.1 as of 3rd of November 2012.
The following will describe the necessary steps to do, please remember that any upgrade of the kernel will require to install the module again!
sudo tar -xvJf xtables-addons-1.47.1.tar.xz
sudo ./configure
sudo make
sudo make install
Optional steps, if you didn't install GeoIP before:
sudo mkdir /usr/share/xt_geoip
sudo aptitude install libtext-csv-xs-perl
sudo /usr/lib/xtables-addons/xt_geoip_dlThis will download the list to the current directory, if you want to change this, do that before execution of this command!
sudo /usr/lib/xtables-addons/xt_geoip_build -D /usr/share/xt_geoip *.csvThis will build the output files in /usr/share/xt_geoip and assumes the GeoIP list is located in the current directory. Please also note, that you have to specify "*.csv", otherwise nothing will happen.
sudo iptables -F && iptables -A OUTPUT -m geoip --dst-cc US -j DROPThis will block all outgoing traffic to IP addresses located in the USA, next you can try to visit Google, this should not work anymore. If you want your firewall changes to be undone, just enter
sudo iptables -F
.References: