PHP Classes

How Can PHP Add IPtables Rule to Block an IP Segment Using the Tor Geoip Tools: Generate IPTables rules to block the range of a IP

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 113 All time: 9,598 This week: 560Up
Version License PHP version Categories
xzygeoip 1.0GNU General Publi...5Networking, PHP 5, Unix, Geography, S...
Description 

Author

This class can generate IPTables rules to block the range of an IP.

It can find the IP range segment of a given IP address by looking up at a GeoIP database in CSV format generated by the Tor project geoip-db-tool command.

The class can output commands with parameters to use the iptables program to block the IP range segment.

The class can also determine the country of a user accessing a Web site based on the IP address of the user's computer.

Innovation Award
PHP Programming Innovation award nominee
July 2022
Number 8
Sometimes Web servers that run PHP sites are attacked by several machines hosted in the same network.

One way to protect against those attacks from all those machines is to block network connections from the whole IP address range segment.

This package simplifies blocking a whole IP address range segment by generating commands to run the Linux iptables command that adds rules to block all the IP addresses that belong to those range segments.

Manuel Lemos
Picture of Luis Martinez Ulloa
  Performance   Level  
Name: Luis Martinez Ulloa is available for providing paid consulting. Contact Luis Martinez Ulloa .
Classes: 12 packages by
Country: Peru Peru
Age: 52
All time rank: 3991 in Peru Peru
Week rank: 227 Up2 in Peru Peru Down
Innovation award
Innovation award
Nominee: 5x

Example

#!/usr/bin/php
<?php

require_once './geoip.php';
require_once
'./geoip.conf.php';
$geoip = new xzy\geoip($geoipPath);
$rule = $geoip->dropSegment($argv[1]);
echo
"$rule\n";


Screenshots (4)  
  • geoip04.png
  • geoip05.png
  • geoip05b.png
  • pgdrop2.png
  Files folder image Files (10)  
File Role Description
Accessible without login Plain text file geoip Data Bonus: geoip file
Accessible without login Plain text file geoip.conf.php Conf. Configuration file
Plain text file geoip.php Class class file
Accessible without login Plain text file index.php Example Web page example
Accessible without login Plain text file pgdrop.php Example Example script
Accessible without login Image file pgdrop.png Photo Example of use

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:113
This week:0
All time:9,598
This week:560Up
User Comments (6)
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star
Tor connects through chains of servers, which means that it ...
2 years ago (SyntaxWEB ?6stPROD? WowSuite)
17%Star