MyBB Community Forums

Full Version: Ban IPs by range
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Need to be able to ban IPs by range in a proper format, for example:
72.1.0.0 - 72.63.255.255

The current method of banning whole blocks of IPs is cumbersome and produces unwanted side-effects - see:
http://community.mybboard.net/showthread.php?tid=25022
An alternative would be to specify an IP and a submask. The range you specified actually covers multiple subnets, the first two being:

Northern Telephone and Data Corp
72.1.0.0/19 = 72.1.0.0-72.1.31.255

TierraNet Inc
72.1.32.0/20 = 72.1.32.0-72.1.47.255
Thanks - a couple of questions:

1) Can myBB banning actually handle IPs entered in the format 72.1.0.0/19 ?

2) Assuming I'm certain I want to ban the whole range 72.1.0.0 - 72.63.255.255 wouldn't that method require far too many entries to be made? I'm just requesting the ability to enter a start and end IP where everything in between would be banned.
I don't believe mybb will ban in the manner that laie suggests.

function get_banned_ips()
{
	global $mybb;
	$banned_ips = explode(",", $mybb->settings['bannedips']);
	$banned_ips = array_map("trim", $banned_ips);
	return $banned_ips;
}

/**
 * Checks if a specific IP address has been banned.
 *
 * @param string The IP address.
 * @return boolean True if banned, false if not banned.
 */
function is_banned_ip($ip_address)
{
	$banned_ips = get_banned_ips();
	foreach($banned_ips as $banned_ip)
	{
		if($banned_ip != "" && strpos($ip_address, $banned_ip) !== false)
		{
			return true;
		}
	}
	return false;	
}

As you can see it does a strpos() which of course won't match a range in the manner suggested.
As I said before this is fixed in MyBB 1.4
Which syntax is used in MyBB 1.4 -- subnets or hyphenated range?
subnets as follows:

127.0.0.*

or

127.*.0.1

or

127.*

etc...
wow, that will be great!
cool! we need that! any hlep to put a stop to those spam trolls !
and competitve sites
Tikitiki Wrote:subnets as follows:

127.0.0.*

or

127.*.0.1

or

127.*

etc...

Does this work in the latest version?
Pages: 1 2