Dec 02 2010

Advanced MRTG Configurations

Introduction

In many cases using MRTG in a basic configuration to monitor the volume of network traffic to your server isn’t enough. You may also want to see graphs of CPU, disk, and memory usage. This chapter explains how to find the values you want to monitor in the SNMP MIB files and then how to use this information to configure MRTG.

All the chapter’s examples assume that the SNMP Read Only string is craz33guy and that the net-snmp-utils RPM package is installed (see Chapter 22, “ Monitoring Server Performance“). Read more …

Oct 22 2009

Simple Web/Linux IP Address Lookup

If you’re going to be doing a lot of Geotargeting or IP Address Lookups, please take a feed instead which will preserve both our bandwidth and your bandwidth.

Simple GET

That said, there is an easy HTTP oriented API to locate IP addresses and Geocode them. If you don’t supply the “?ip=aa.bb.cc.dd” bit, then the ip address lookup of the calling machine will be located instead (here, the aa,bb,cc,dd are decimal digits). If you add &position=true to the end of the URL then latitude and longitude will be returned also. Both HTML and XML formats are supplied for your convenience.

http://api.hostip.info/country.php
US

http://api.hostip.info/get_html.php?ip=12.215.42.19
Country: UNITED STATES (US)
City: Sugar Grove, IL

http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588

http://api.hostip.info/?ip=12.215.42.19
[use the URL above for an example - XML too long to paste below]

Read more …

Jun 16 2009

Simple Check IP with PHP

You can use below simple PHP scripting to check IP address

<?php
if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
echo “<title>”.$_SERVER["HTTP_X_FORWARDED_FOR"].” via “.$_SERVER["REMOTE_ADDR"].”</title>\n\n”;
echo “Your IP: “.$_SERVER["HTTP_X_FORWARDED_FOR"] . “<br />\n”;
echo “Proxy IP: “.$_SERVER["REMOTE_ADDR"] . “<br />\n”;
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}else{
echo “<title>”.$_SERVER["REMOTE_ADDR"].”</title>\n\n”;
echo “Your IP: “.$_SERVER["REMOTE_ADDR"] . “<br />\n”;
$ip = $_SERVER["REMOTE_ADDR"];
}
echo “Date Time: ” . date(”Y-m-d H:i:s”) . “<br />\n”;
?>

I found good examples for this.

- Quick HOWTO (from LinuxHomeNetworking.com) – download

- Sample IPTABLES Configuration (RedHat/CentOS) – download

Feb 20 2009

How to protect your website using simple PHP scripts

Just put below on your top line of the scripts :

$ips = array(”127.0.0.1″,”aaa.bbb.ccc”,”xxx.yyy.zzz”);
$userip = $_SERVER['REMOTE_ADDR'];
foreach ($ips as $ip) {
if (!preg_match(”/$ip/i”, $userip)) {
echo “Access Denied!”;
exit;
}
}

Notes:
$ips is the allowed IP address range

Other way, you can use .htaccess to protect directories/files.