Ban an IP Address From The Server Published: Mar 17, 2005
  • Rating

    3/5

Have a user that keeps hammering your FTP or trying to login over and over and over again that you just want to ban and never see again? We'll show a quick and dirty method to ban an IP address from the server.

Have a user that keeps hammering your FTP or trying to login over and over and over again that you just want to ban and never see again? We'll show a quick and dirty method to ban an IP address from the server.

We commonly receive questions like:
"I would like to ban that ip address to prevent the access to the server.

how can i ban that Ip address from the server?"

Simple!

1) Login to the server as and su  - to root.

2) If you are running iptables, you can enter:

iptables -A INPUT -s <IP> -j DROP

3) If you have APF firewall installed

apf -d <ip>

4) When you reboot this IP ban will be removed, meaning the IP will no longer be banned anymore.
If you have APF you can get around this by opening the deny hosts file.

pico /etc/apf/deny_hosts.rules

Scroll to the bottom and paste in the IP address.
Ctrl+X then Y to save the changes and exit.

5) Restart APF
/etc/apf/apf -r

  • Rating

    3/5

Related Articles

Comments (10)

  • Gravatar - agreseanu vlad
    agreseanu vlad 16:49, October 25, 2005
    how i can ban a intruder? i know his ip<br />
    <br />
  • Gravatar - Dusty
    Dusty 12:49, April 18, 2006
    Do you people really enjoy banning other people,,Is it in your nature to do this.Maybe you should be ban as well to see how it feels.
  • Gravatar - tomofumi
    tomofumi 13:42, September 12, 2006
    Acutally you can save the current iptables entries and keep the setting after reboot by running "service iptables save"
  • Gravatar - jethbrown
    jethbrown 15:14, July 17, 2007
    Is there a way to ban a ip range with APF? Reason I am asking is for banning the Panscient Data Services bot, that seems to hammer my server regularly.<br />
    <br />
    Read about it here: http://web-robot-abuse.blogspot.com/2006/09/panscientdataservices.html<br />
    <br />
    Or is there a way to see the specific IP's they are using to block those?
  • Gravatar - omid
    omid 21:33, October 19, 2007
    how can i delete an ip from the iptables?
  • Gravatar - Jim
    Jim 18:54, September 29, 2008
    When calling IPtables the first argument is the action. So -A is add, so you can guess how deleting is done:<br />
    <br />
    iptales -D <the rest><br />
    <br />
    When i forget <the rest> i always run iptables-save, then you will (save) get a list with all rules in detail with <the rest> info.<br />
    <br />
  • Gravatar - maybe
    maybe 01:31, December 10, 2009
    dfdsfafasfasfsafsadfdfdfdsfdsfds
  • Gravatar - shag
    shag 06:05, December 10, 2009
    I've found that using a .htaccess file is a pretty easy way to handle this. I'm no expert but it seems to work well for me. I created a .htaccess file and placed it above my publicly accessible directories (so it applied to all my sites) and used this...<br />
    # allow all except those indicated here<br />
    <Files *><br />
    order allow,deny<br />
    allow from all<br />
    deny from xxx.xxx.xxx.xxx<br />
    deny from .*blahblah\.com.*<br />
    </Files> <br />
    this is on apache of course and I used vim to create and edit the file while I was logged in as root. Like I said, I'm no expert but it worked on my server.
  • Gravatar - mhineqhoe
    mhineqhoe 03:15, January 21, 2010
    plz. give me some IP ban
  • Gravatar - xander
    xander 01:27, January 31, 2010
    how about banning a mac address in cpanel? Is that possible on the server level? Tnx

Add Your Thoughts

WebHostGear.com is a hosting directory, not a web host.

Copyright © 1998-2024 WebHostGear.com