how do you block ip addresses to visit your site?

Discussion in 'Security' started by aff_newbie, Dec 20, 2006.

  1. #1
    my logs are insane. SO many fraudulent clicks from a couple different ip addresses...
     
    aff_newbie, Dec 20, 2006 IP
  2. netfreehost

    netfreehost Peon

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can block IP from visiting your site with .htaccess, to do this add

    deny from XXX.XXX.XXX.XXX
     
    netfreehost, Dec 21, 2006 IP
  3. wormy

    wormy Active Member

    Messages:
    1,112
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Use iptables instead, thats what I use...mainly because I dunno how to use .htaccess but I heard iptables is more efficient anyway lol.
     
    wormy, Dec 24, 2006 IP
  4. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #4
    the htaccess method mentioned below is perfect if you have NO access to server admin

    iptables usually only is accessible if you are lucky root server owner

    the syntax for iptables usage would be

    iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP

    replace xxx.xxx.xxx.xxx with the IP you want to block
    iptables is more resource efficient - while htaccess still uses apache to deny access.
    a full example would be a mail-spammer on my server

    iptables -A INPUT -s 209.9.148.130 -j DROP

    if your IP belongs to a network that has several IPs abusing your site and NO real visitors originating
    then instead of the single IP to block you may want to block an entire netmask ( subnet )

    a real example would be a repeated hacker attempt
    from 66.135.34.160
    hosted at ServerBeach Texas - apparently a hosting company paying little or no attention to their hosted sites cleanliness - hence I blocked an entire IP-range

    iptables -A INPUT -s 66.135.32.0/20 -j DROP

    the range to block is found by
    1. finding the network range to block using
    whois 66.135.34.160
    resulting in
    NetRange: 66.135.32.0 - 66.135.47.255
    and then finding the netmask to enter after the
    /
    in your iptables filter line
    using the online subnet mask info found at
    http://xtronics.com/reference/ip-subnetmasks.htm
     
    hans, Jan 6, 2007 IP
  5. WebGeek182

    WebGeek182 Active Member

    Messages:
    510
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    95
    #5
    This should help...put this in your .htaccess:

    # allow all except those indicated here
    <Files *>
    order allow,deny
    allow from all
    deny from 12.345.67.890
    deny from .*domain\.com.*
    </Files>


    You can find more info on .htaccess and IP blocking.
     
    WebGeek182, Feb 22, 2007 IP
  6. tespio

    tespio Peon

    Messages:
    16
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well basic iptables is much more complex than that. And full iptables is very much more than much more :D. Anyway you can add custom rules that in the same time can allow acces to one host to some services and dissalow it to others. There is alot of iptables excellent documentation out there. But then again if you are not the server owner .htaccess is just as good.

    P.S.: that doesnt apply for synacc requests and or DoS/DDoS attacks. You might need to ask your hosting provider or as is the case uplink ISP or even go to the closest border router to add in depth filtering on IP or IP's ranges/netblocks.
     
    tespio, Feb 26, 2007 IP
  7. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I second that :-D and then edit the 403 page which shows the result page of banned users.
     
    Lordy, Feb 26, 2007 IP
  8. penelope.garcia

    penelope.garcia Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    hello,

    I new little about how to block ip ....and the information in this thread is pretty good...

    I have a query regarding the ip of a site.....

    if there are 10 sites from the same ip....... how the site's are judged by google.......please let me know about this ...
     
    penelope.garcia, Dec 30, 2009 IP
  9. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #9
    The best way to block ip addresses is using a firewall. Look for blocks of IPs and ban it. Use CSF or APF firewall
    see this tutorial
     
    olddocks, Jan 2, 2010 IP
  10. edenCC

    edenCC Member

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    The easiest way shoule be add this ip address into /etc/hosts.deny, then all services that have tcpwappers integrated will be unavailable to this address.
     
    Last edited: Jan 10, 2010
    edenCC, Jan 10, 2010 IP
  11. eyeofskadi

    eyeofskadi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Use Zone Alarm Pro Firewall as it blocks most of the attacks.
     
    eyeofskadi, Jan 27, 2010 IP
  12. BizPhil

    BizPhil Member

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #12
    Definitely block the ip from your firewall level that way it will be blocked 24/7 and at your closest entrance to your network. If you are using iptables, firewall software, router firewall, etc... make sure you use a DROP rule. It's more effective if the target is doing a scan on you, they will most likely believe your site is down instead of any other type of blocking.
     
    BizPhil, Mar 20, 2010 IP
  13. VarriaStudios

    VarriaStudios Member

    Messages:
    246
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #13
    from your web hosting control panel you ought to be able to block by IP number.

    this has nothing to do with your local firewall unless youre hosting the files from your own server.
     
    VarriaStudios, Mar 20, 2010 IP