Geoip, IPtables and Xtables v3.13 on uBuntu 20.04LTS

I still have a num­ber of places where I use geolo­ca­tion with ipt­a­bles on 20.04LTS.

One of the chal­lenges of 20.04LTS is keep­ing xta­bles up to date.

I do this by cus­tom com­pil­ing the xta­bles from source as required (such as after a ker­nel upgrade).  Here is a quick snip­pet on how I do this (sor­ry this is not a full arti­cle at this time).

Remove the default repos­i­to­ry ver­sion of xta­bles and install depen­den­cies for cus­tom compile.

$ dpkg --get-selections | grep xtables
$ lsmod | grep geo
$ sudo apt purge xtables-addons-common xtables-addons-dkms xtables-addons-source
$ sudo apt autoremove
$ sudo apt install git build-essential autoconf make libtool libxtables-dev libip6tc-dev libip4tc-dev libxtables-dev pkg-config libnet-cidr-lite-perl libtext-csv-xs-perl

Clone the source and compile

$ cd ~
$ git clone xtables-addons-xtables-addons
$ cd xtables-addons-xtables-addons
$ ./
$ ./configure
$ make
$ sudo make install
$ sudo depmod -a
$ sudo modprobe xt_geoip
$ lsmod | grep geoip

Add to dynam­ic ker­nel modules

$ sudo nano -w /etc/modules-load.d/modules.conf

Run your script for your coun­try IP codes from Max­mind, DBIP, etc.

Orig­i­nal­ly Post­ed: Jan­u­ary 12, 2021
Updat­ed: Octo­ber 3, 2021

| Arti­cle post­ed in: Bit­stream || Tagged as: , , |