Category: Nerd Stuff

Uploading Prosper202 GEOIP Database remotely on memory limited hosts.

Like me, you may be hosting your Prosper 202 installation on a cheap hosting account. This may lead to issues if you want to import the GEOIP database so you can track by country. Many hosts won’t allow a file this large (20 something megabytes) via phpmyadmin.

So, how do you get around this? In my case, it was pretty simple.

I went to the control panel for my hosting, added a new database user that was allowed to connect from anywhere.

Then I scp’d or ftp’d my GEOIP database up to another host with mysql command line access.

Then I simply issued this command, and it imported it for me. No Fuss, no Muss.

# mysql -h HOSTNAME -u USERNAME -p DATABASENAME < geoip_database.sql

When you press enter, it’ll ask you for your password, and then take a few minutes to pop the content over. Now you’re done.

Note my database went up from .5 megabyte, to 50 megabytes after the import, so make sure you have the space available on your host.

Listing all IP’s on a Linux Server when Setting up a Squid Proxy made easy with this script

A few days ago a buddy of mine asked me to setup Squid Proxy on his server. He wanted the ability for it to listen on all available IP’s on the box (512 of them). So, if you used proxy at x.x.x.x it would go out x.x.x.x and y.y.y.y would go out y.y.y.y and so on. After a little digging we found a neat little script written for FreeBSD that would parse all available IP’s on the box and generate the squid configuration for you, saving hours of tedious hand typing. We modified the script to work on Linux, and here it is;


#!/usr/bin/perl

open(IFCONFIG, "ifconfig eth0 |");

$count=1;
@acls = ();
@tcps = ();

while (<IFCONFIG>) {
if (/inet addr/) {
s/^s+//;
@tokens = split(/:/);
if (! ($tokens[1] =~ "127.0.0.1")) {
push(@acls, "acl ip$count myip $tokens[1]n");
push(@tcps, "tcp_outgoing_address $tokens[1] ip$countn");
$count++;
}
}
}

close(IFCONFIG);

foreach $acl (@acls) {
print $acl;
}

foreach $tcp (@tcps) {
print $tcp;
}