Simple IP Information / IP to Location (Country) Lookup

IP Facts

A colleague of mine recently released a new website, which I thought was brilliant enough to blog about. Simply, the website displays IP Facts, without all the crap and ads we normally have to put up with. Simply put sysadmins, it’s simple and gets straight to the point – something hard to come across.

With a little assistance, we also got it to lookup the details of a supplied IP address, which I find helpful when checking abusive IP addresses.

Get your IP Facts – http://ipfacts.info/

Linux / SSH Console Commands

Of course if you have a console window open, you can typically get most of this information using a few commands.

Find your server’s interface IP address:

ifconfig

Check what an IP address resolves to:

host iphere
host 122.122.122.122

Check what hostname an IP address resolves to:

host domain.com
host google.com

As for what country an IP belongs to, this isn’t as easy. You can run a whois and see who the IP is owned by, but that isn’t always the correct country for international corporations, but even then that’s no promise you’ll get any information if any:

$ whois 122.122.122.122
[Querying whois.apnic.net]
[Redirected to whois.twnic.net]
[Querying whois.twnic.net]
[whois.twnic.net]
Chunghwa Telecom Data Communication Business Group

Netname: HINET-NET
Netblock: 122.122.0.0/16

Administrator contact:
network-adm@hinet.net

Technical contact:
network-adm@hinet.net

In the case of the above, the IP to Country script comes in handy because the database is build from another source.

1 Comment

HTTP Status Code Drinking Game

I’ve started working with a new sysadmin the last few weeks (hey Dan if he’s reading). Like all sysadmins, they bring a new flavour to the game of work. Dan shared this with me, which I couldn’t help but share with everyone else. Welcome to the status code drinking game! If you’re a techy kind of person, or work in web development, you might get a kick from this.

http://statuscodedrinkinggame.com/

Some samples for your amusement:

404 Not Found
Last person to make a greeting must drink.

416 Request Entity Too Large
Thats what she said! Everyone drinks.

403 Forbidden
Miss a turn, Must drink double on next turn.

Check out the website for more.

So at your next departmental party, get all the sysadmins  together and try out this status code drinking game! I’m looking forward to it.

Leave a comment

Modifying cPanel Mailbox Quota Errors “invalid maildirsize file”

My sysadmin email address which server notifications come to started getting emails about a mailbox quota getting close on a cPanel server. I logged into the client’s control panel to increase their mailbox quota, I found the account, doubled the quota and went to save it when I got the following error message:

invalid maildirsize file

While I didn’t actually check the size of the user’s mailbox in file size, which I would have done with:

du -sch /home/username/mail/domain.com/john.smith/*

I would have found that the actual usage was near zero, while cPanel was reporting the mail box usage was over 200mb.

The cause of the invalid maildirsize file error message is a corruption in the maildirsize file – as the error might suggest. It is no longer accurately keeping track of the usage properly. The solution is simple, all you need to do is delete the file and it will rebuild itself without a problem (will occur on new activity like a login or modification of quota).

There are two common ways of deleting it. First is to login to your server via SSH. The follow example applies where the email address is john.smith@domain.com, and the account username is “username”. Substitute the values in bold.

cd /home/username/mail/domain.com/john.smith/
rm -f maildirsize

That’s all there is to it for SSH.

The second method is probably more easier for the laymen, FTP. Login to the account with the primary login details (e.g. username will be the account username [avoid the sub user FTP accounts], and the password the account password). Browse to:

/mail/domain.com/john.smith/
Delete file named maildirsize

Problem solved. The disk usage dropped back to zero and I’ve not received any more annoying emails since, and the quota reset didn’t give me a invalid maildirsize file error message.

4 Comments