Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ban IPs by range
#1
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
Reply
#2
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
Reply
#3
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.
Reply
#4
This user has been denied support. This user has been denied support.
I don't believe mybb will ban in the manner that laie suggests.

Code:
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.
Reply
#5
As I said before this is fixed in MyBB 1.4
Dennis Tsang
http://dennistt.net
Reply
#6
Which syntax is used in MyBB 1.4 -- subnets or hyphenated range?
Reply
#7
subnets as follows:

127.0.0.*

or

127.*.0.1

or

127.*

etc...
Reply
#8
wow, that will be great!
Official Arabic Translator.
Reply
#9
cool! we need that! any hlep to put a stop to those spam trolls !
and competitve sites
Even Lies Can't keep a good man down. Heart
Reply
#10
Tikitiki Wrote:subnets as follows:

127.0.0.*

or

127.*.0.1

or

127.*

etc...

Does this work in the latest version?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)