Announcement

Collapse
No announcement yet.

Blocking multiple IP Addresses

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Blocking multiple IP Addresses

    Hi everyone,

    I have a little dilemma... I want want to block out some IP addresses using their host address. I'm using @gethostbyaddr($REMOTE_ADDR); to get the host address.

    For example:

    Let say the IP address is 123-334-22-422.hater.attbi.net, how would I block out all IP's with the "hater.attbi.net" extention?

    I've already tried using this:

    $jerk_ip = @gethostbyaddr($REMOTE_ADDR);

    if ($jerk_ip == "^.hater.attbi.net") {
    exit();
    }

    But, no luck. Can someone help me out, please? Thanks a lot.

  • #2
    PHP Code:
    if(preg_match('/\\.hater\\.attbi\\.net$/', @gethostbyaddr($REMOTE_ADDR))) {
      exit;

    Comment


    • #3
      Thanks for the reply.

      How would I do that for multiple addresses though? What would be the most efficient way to do so? Thanks.

      Comment


      • #4
        preg_match is a waste of resources for this.

        strpos would be better suited for the task at hand: http://www.php.net/manual/en/function.strpos.php .

        Comment


        • #5
          go to Arin.net and put the IP address in the whois box. It will bring back all the IP's provisioned to that company in that range.

          Comment


          • #6
            I used preg_match because it looked like he wanted a regular expression.

            Comment


            • #7
              Have we got anymore news on this? It would indeed come in handy.

              Comment


              • #8
                go for Apache blocking and place this in a .htaccess

                Code:
                Deny from .mybanned.host.net
                Scott MacVicar

                My Blog | Twitter

                Comment


                • #9
                  Ok thanks Scott !

                  Comment


                  • #10
                    Originally posted by Scott MacVicar
                    go for Apache blocking and place this in a .htaccess
                    Does that work if Apache is set to not resolve IPs?

                    Comment


                    • #11
                      You can prevent apache from resolving IP's? I was under the impression it always tried to resolve them.
                      Scott MacVicar

                      My Blog | Twitter

                      Comment


                      • #12
                        By default it's off I think
                        Code:
                        #
                        # HostnameLookups: Log the names of clients or just their IP addresses
                        # e.g., www.apache.org (on) or 204.62.129.132 (off).
                        # The default is off because it'd be overall better for the net if people
                        # had to knowingly turn this feature on, since enabling it means that
                        # each client request will result in AT LEAST one lookup request to the
                        # nameserver.
                        #
                        HostnameLookups Off
                        (taken from Apache cvs, apache-1.3/conf/httpd.conf-dist)
                        Last edited by MUG; Sun 29th Jun '03, 4:27am.

                        Comment


                        • #13
                          http://httpd.apache.org/docs/mod/cor...ostnamelookups

                          Regardless of the setting, when mod_access is used for controlling access by hostname, a double reverse lookup will be performed. This is necessary for security. Note that the result of this double-reverse isn't generally available unless you set HostnameLookups double. For example, if only HostnameLookups on and a request is made to an object that is protected by hostname restrictions, regardless of whether the double-reverse fails or not, CGIs will still be passed the single-reverse result in REMOTE_HOST.

                          Comment

                          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                          Working...
                          X