Thursday, July 26, 2012

Block ip address with iptables

To block a traffic from a certain ip address to your machine because eg. it's doing a hacking:

  • Check DNS of this address to be sure you're not blocking someone important:
    $ dig ip_address
  • Add new rule in iptables:
    $ iptables -A INPUT -s ip_address -j DROP
  • In Redhat based distributions (Fedora, CentOS, Enterprise Linux):
    $ service iptables save