The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

IP ban of server?

Discussion in 'General Discussion' started by dark_hunter, Aug 17, 2009.

  1. dark_hunter

    dark_hunter Member

    Joined:
    Aug 17, 2009
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Hello. Is there a way to ban someones IP so they can't get on any website on the server?
     
  2. rahulm

    rahulm Member

    Joined:
    Jan 19, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hello,


    Yes, you can ban ip on server using following command.

    route add ipaddress reject.

    If you want to blcok ip for single site then use cpanel >> ip deny manager. It will deny ip to access site.

    Regards,
    Rahul Mudavadkar
     
  3. Sean.barron

    Sean.barron Active Member

    Joined:
    Aug 16, 2008
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Yes, if its only a handful number of ip addresses that you want to ban, put them in an array and check against that. cPanel ip banning feature is very useful to do this.
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    You can add the IP to the blocklist in most firewall applications
    such as CSF or APF or directly enter a filter in iptables:
    Code:
    iptables -A INPUT -s x.x.x.x -j DROP
    
    (Where x.x.x.x is the IP address or CIDR range you want to block)
     
  5. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    There are several ways of doing this. Another one is the /etc/host.deny file.
     
  6. dark_hunter

    dark_hunter Member

    Joined:
    Aug 17, 2009
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    How would I edit the file?
     
  7. InstaCarma_Tech

    InstaCarma_Tech Well-Known Member

    Joined:
    Apr 22, 2009
    Messages:
    228
    Likes Received:
    1
    Trophy Points:
    18
    To edit that file or for that matter, any of these methods would need 'root' access to the server.

    If you are using APF/CSF, you can simply block an IP by using the following command:

    csf -d XX.XX.XX.XXX
    OR
    apf -d XX.XX.XX.XXX

    And restart the firewall after that.

    Again, you would need 'root' access to the server.
     
  8. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Thinking more basic than entire server ....

    If you just have a Cpanel account and are not the server administrator,
    you can block an IP or CIDR range from your site with .htaccess:
    Code:
    Order Allow,Deny
    Deny from x.x.x.x
    
    'x.x.x.x' could be a single IP address, CIDR range, or domain (such as ISP name)
     
  9. dark_hunter

    dark_hunter Member

    Joined:
    Aug 17, 2009
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Thanks, but I do have ROOT access.
     
  10. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Well, then you have all the options we gave earlier!

    /etc/hosts.deny

    Block in Firewall

    Setup an IPTables Filter

    Dead route the packets

    In addition, you can also block the IP in the Security Center under WHM as yet another way of dropping the connection from a certain IP.

    Like was said above, you got many ways of doing this! ;)
     
Loading...

Share This Page