Install Perl Geo::IP cpan module on Centos 5 or 6

Installing this Perl module from cpan can be a bit tricky, as it looks for the GeoIP libraries in the wrong place.

You may see messages like this in the output when running : cpan Geo::IP

  • The GeoIP CAPI is not installed you should do that
  • GeoIP must be installed prior to building Geo::IP and I can’t find it in the standard library directories

It’s also compounded by the fact that currently Centos is shipping with a version of GeoIP-devel prior to 1.5, so you can’t install the GeoIP libraries via yum. I tried installing it from yum, and then got this error:

  • Your installed version of libgeoip is outdated!

Here’s the quick solution:

First, compile the GeoIP libraries from the C Source using the default configuration. This is all available from:

http://dev.maxmind.com/geoip/legacy/downloadable/

wget http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz;
tar xzf GeoIP-latest.tar.gz
cd GeoIP-1.5.1
./configure
make
make check
make install

Now we (hopefully) have the geoip libraries installed, and the latest database installed in /usr/local/share/GeoIP/GeoIP.dat

So, back to cpan. First, enter the cpan> shell (just run the cpan command on it’s own). Then enter the following command to fetch and locate the package installation files:

look Geo::IP

This will locate and download the source package for the module, and put you in the installation directory e.g.

/steve/.cpan/build/Geo-IP-1.42-V2q_q_

So, now we need to tell the package installer where to find the GeoIP libraries we previously installed from source and install the module manually.

perl Makefile.PL LIBS='-L/usr/local/lib' INC='-I/usr/local/include';
make;
make test;
make install
Leave a comment

iPhone iPad – Sent Items not updating correctly

Sometimes the iPhone or iPad won’t automatically detect the correct Sent Items IMAP folder on the server and will resort to storing Sent Items locally. Very annoying. Here is how to correct this on the iPhone – it’s very similar for the iPad.

Step 1

Open the settings icon and then click on the problem email account.

Step 2

Click on the Account button to edit the account settings.

Step 3

Scroll right to the bottom and click on the Advanced button.

Step 4

Click on the Sent Mailbox button

Step 5

Click on the appropriate “Sent” folder under the On the Server section. You will probably see that the On My iPhone – Sent folder is currently set. Once you are done click in the top left to go back to the previous Advanced screen, then then again to return to the Account screen. Then, importantly, click the Done button to save the changes.

1 Comment

Search modsecurity logs more easily

Searching a SERIAL modsec audit log can be a pain. The reports are spread over various sections, and require grepping over multiple lines which is, well, not possible.

cPanel/WHM creates the logfile in /usr/local/apache/logs/modsec_audit.log

This perl script will search the log for Intercepted requests for a particular IP address

  1. #!/usr/bin/perl
  2.  
  3. # usage modsearch.pl [optional ip address]
  4.  
  5. my $ip;
  6.  
  7. if ($#ARGV == 0 ) {
  8. $ip = $ARGV[0];
  9. }
  10. # you can comment out this line to search for things other than IP address
  11. if ($ip !~ /(\d{1,3}\.){3}\d{1,3}/) {$ip='.';}
  12.  
  13. my $modseclog = '/usr/local/apache/logs/modsec_audit.log';
  14.  
  15. if (open LOGF, "<$modseclog") {
  16. # read log into array
  17. my $chunk, $line, $count;
  18. while (($chunk = <LOGF>) && !eof) {
  19. # go hunting for A entry
  20. if ($chunk =~ /--[\d\w]+-A--/) {
  21. do {
  22. $line = <LOGF>;
  23. $chunk .= $line;
  24. } until ($line =~ /--[\d\w]+-Z--/ || eof)
  25. }
  26. if ($chunk =~ m/${ip}.*Intercepted/s) {
  27. $count++;
  28. print $chunk;
  29. }
  30. }
  31. close LOGF;
  32. print $count, " matches found.\n";
  33. }

This script will output the complete sections (between A and Z) for each incident, making it much easier to track down problems.

Leave a comment

FREE Business Class UK Web Hosting

Krystal - UK Web Hostinghttp://www Krystal.co.uk are giving away 600 FREE hosting plans to celebrate the Queen’s Diamond Jubilee.

  • Full Amethyst Plan 100% FREE! (1st Year)
  • 500 MB UK Web Space
  • 25 GB Bandwidth
  • Host 2 Different Websites
  • cPanel, PHP, MySQL, Cron, SSH
  • No contract/CC required

See All Features

Krystal have done business differently for a decade. Our web hosting has ALL the tools you need to easily run a successful website. Databases, web stats, email filtering, backups and much more are all included. We’re 100% UK based and always will be.

Terms: Enter discount code “GodSaveTheQueen” at checkout to claim. Offer open to new and current clients. Limit 1 per client. Valid 2nd – 17th June 2012

Leave a comment

Mod_userdir URLs no longer work since Mod_ruid added

Just a quick one for today. I found that after recompiling apache with mod_ruid that mod_userdir is broken and would no longer serve pages from the customer’s vhost domain, and would only serve them from the server’s main URL.

http://customerdomain/~customerusername will no longer work

http://defaultserverhostname/~customerusername continues to work normally

This is due to permissions issues since the requests are now being served by the nobody account.

Leave a comment

How to update NATS Aware using a Mac without losing saved routes

According to www.airspaceaware.com in order to update the NATS Aware unit using a Mac, you simply overwrite the SD card with the contents of the airspace update.

More specifically, you download the latest airspace update file which will be named something like

Airac[month][year].update

e.g. Airac0212.update

The problem

Using the above example, we rename Airac0212.update, to Airac0212.zip, unpack it, and then copy the contents of the resulting Airac0212 directory into the root of the SD card. Simple enough, but this totally destroys any saved routes on the device.

NATS Aware Routes DatafileThe solution

I found that by copying the file

/Data/User/Route

from the SD card to somewhere safe (shown opposite) – then performing the update as usual, and then finally copying my old Route file back onto the SD card, that any saved routes are preserved. I notified Airbox Aerospace of this, and they confirmed that “all seems to work fine with this process”.

Leave a comment