Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Blocking IP address or User from viewing your site

Options
  • 18-12-2003 12:22pm
    #1
    Closed Accounts Posts: 1,362 ✭✭✭


    I was wondering if there is a way of blocking IP range or specific people from viewing your website.


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    You should be able to do so either at the server level or, if you don’t control the server, using server-side scripting. It entirely depends upon what your set-up is.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    See mod_access.

    adam


  • Registered Users Posts: 7,412 ✭✭✭jmcc


    Originally posted by dahamsta
    See mod_access.

    adam

    Also mod_rewrite as it allows you to forward blocked IPs to a custom 403 page or a completely different site. It also works on an IP basis.

    http://httpd.apache.org/docs/mod/mod_rewrite.html

    The .htaccess file can also be used on a directory by directory basis instead of using rewrites in httpd.conf.

    Regards...jmcc


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    How bout use a simple php function?

    This is just for restricting one address.

    restrict.php:

    <?
    $address = $REMOTE_ADDR;
    if ($address == "194.165.163.90") {
    print ("Error you are restricted");
    exit();
    }

    ?>

    file.php:


    <? include ("restrict.php"); ?>

    <HTML>
    <TITLE> </TITLE>
    <BODY> .......


    Restricting a range could be a little more difficult, having to using regular expressions in crap and loop it...but i'm too tired to even begin to think where to start with that now ;)


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Blocking IPs via .htaccess is nice and simple and works wonders ...


  • Advertisement
  • Moderators, Politics Moderators Posts: 39,950 Mod ✭✭✭✭Seth Brundle


    unless they have a dynamic IP or different ISPs


  • Registered Users Posts: 7,412 ✭✭✭jmcc


    Originally posted by blacknight
    Blocking IPs via .htaccess is nice and simple and works wonders ...

    And it can work for entire countries if you have the proper IP database. :) Some of the simple free ones vary considerably in quality though and are not reliable.

    Regards..jmcc


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Yes John, however I doubt if they need to go to those lengths :)


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    Originally posted by kbannon
    unless they have a dynamic IP or different ISPs

    ...or a machine at home and another one at work etc. They could use a web cafe, or even a friends PC's.


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Only real solution is to make the entire site 'member only' and block their email address, or put them in 'jail'
    Of course that can be circumvented as well


  • Advertisement
  • Closed Accounts Posts: 135 ✭✭dynamic.ie


    I've used IP blocking to restrict access to admin areas on website when admin will only be using the system from 1 machine on a dedicated IP. Can do this in ASP/VB like this:

    <%
    'Pull out the IP from the server variables
    strIP = Request.ServerVariables("REMOTE_ADDR")

    'Do a simple redirect if not the correct ip
    IF strIP <> "192.264.23.2" THEN
    Response.Redirect("noaccess.asp")
    ELSE
    Response.Redirect("fullaccess.asp")
    END IF
    %>

    You can reverse this idea and using a long string of IP's you can block full ranges:

    <%
    'Pull out the IP from the server variables
    strIP = Request.ServerVariables("REMOTE_ADDR")

    'Set a list of blocked IP's
    strBlockedIP = "129.39.392.3, 129.39.392.4, 129.39.392.5, 129.39.392.10, 129.39.392.11"

    'See if the strIP appears in the strBlockedIP and if so redirect to noaccess.asp
    IF InStr(strBlockedIP, strIP) > 0 THEN
    Response.Redirect("noaccess.asp")
    ELSE
    Response.Redirect("fullaccess.asp")
    END IF
    %>

    You could use that as a base and probably convert it to another programming language if you don't have access to ASP.

    Also, as an additional bit of security against the user changing ISP and coming back to your site with a completely new IP address, you could do the following based on the above:


    <%
    'Pull out the IP from the server variables
    strIP = Request.ServerVariables("REMOTE_ADDR")

    'Set a list of blocked IP's
    strBlockedIP = "129.39.392.3, 129.39.392.4, 129.39.392.5, 129.39.392.10, 129.39.392.11"

    'See if the strIP appears in the strBlockedIP and if so redirect to noaccess.asp
    IF InStr(strBlockedIP, strIP) > 0 THEN

    'Lets write a cookie on their machine, saying that they were denied access
    Response.Cookies("websitename")("noaccess") = "y"
    Response.Cookies("websitename")("noaccess").Expires = Date() + 365
    Response.Redirect("noaccess.asp")

    ELSE

    'They got passed the IP check but now lets see if they were blocked on a previous occasion
    strBlockedCookie = Request.Cookies("websitename")("noaccess")

    IF strBlockedCookie = "y" THEN

    Response.Redirect("noaccess.asp")

    ELSE

    Response.Redirect("fullaccess.asp")

    END IF

    END IF
    %>

    Hope that helps you or someone out there....

    Cheeurs, Dave


  • Closed Accounts Posts: 1,362 ✭✭✭the Guru


    Thanks For all you help gents

    Its an Eircom Pop range of IP address in a certain town in Ireland That I want blocked for security reaons on the bungee website.

    So I take it this can be done

    Good off to Eircom net the get the range,


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    If you've got the IP range you'll be able to block it without any problems


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Originally posted by the Guru
    Thanks For all you help gents

    Its an Eircom Pop range of IP address in a certain town in Ireland That I want blocked for security reaons on the bungee website.

    So I take it this can be done

    Good off to Eircom net the get the range,

    You will have probs tho if those people go through other ISPs or Proxys


  • Moderators, Politics Moderators Posts: 39,950 Mod ✭✭✭✭Seth Brundle


    Originally posted by the Guru
    Thanks For all you help gents

    Its an Eircom Pop range of IP address in a certain town in Ireland That I want blocked for security reaons on the bungee website.

    So I take it this can be done

    Good off to Eircom net the get the range,
    Declan, did someone try and hack into it?


  • Closed Accounts Posts: 1,362 ✭✭✭the Guru


    No killion

    Im updating the site with some new deals etc and there is certain people I dont want to see it .
    You will have probs tho if those people go through other ISPs or Proxys

    I know for a fact that Eircom.net is there ISP so blocking the IP range from that Exchange will work [I Hope]


  • Registered Users Posts: 944 ✭✭✭nahdoic


    That sounds like some crazy way to try to solve your problem. What are you trying to hide?

    People talk - and putting a deal on a website, especially if it's a good deal isn't a good way of keeping a lid on it. Not to mention good business, honesty and openness.


  • Closed Accounts Posts: 1,362 ✭✭✭the Guru


    Originally posted by nahdoic
    That sounds like some crazy way to try to solve your problem. What are you trying to hide?

    People talk - and putting a deal on a website, especially if it's a good deal isn't a good way of keeping a lid on it. Not to mention good business, honesty and openness.

    Yes nahdoic but its the easiest way I know of not letting the compitition know what i am up to but still get the message across to the general public


  • Closed Accounts Posts: 66 ✭✭usualsuspect


    Instead of a 403 you could redirect them to a phoney version of your site :D, if you completely block access they might get suspicious...


Advertisement