How to Block an IP Address Using IPtables

How to Block an IP Address Using IPtables thumbnail
Block IP addresses

Iptables is a user space application tool in the Linux operating system. It is a firewall that allows administrators to filter network packets of Internet protocol by defining rules for accepting or rejecting network traffic. It comes with the distribution of Linux and its common use is to allow or drop (block) specific IP addresses. Iptables is an efficient method to protect your machine from hackers and other invaders.

Things You'll Need

  • Administrator privileges
Show More

Instructions

  1. Adding an IP Address to the Iptables

    • 1

      Open a "Terminal Window," which is a Linux application that enables running Linux commands and software applications. In Ubuntu, one of the most popular distributions of Linux operating system, the terminal is launched using the "Ctrl+Alt+T" shortcut. Once the terminal window is opened, the Linux command prompt appears.

    • 2

      Type "sudo /sbin/iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP" in the terminal window where xxx.xxx.xxx.xxx is the IP address that you wish to block.

    • 3

      Type "sudo /sbin/iptables -L -n" in the terminal window to verify that the blocked IP address appears in the Iptables. The output of this command shows the current Iptables rules, including the list of the blocked IP addresses.

    Removing an IP Address from the Iptables

    • 4

      Open a "Terminal Window," as described in Section 1.

    • 5

      Type "sudo /sbin/iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP" in the terminal window where xxx.xxx.xxx.xxx is the IP address that you wish to remove from the block list.

    • 6

      Type "sudo /sbin/iptables -L -n" in the terminal window to verify that the blocked IP address was removed from the Iptables.

Related Searches:

References

  • Photo Credit access denied image by UBE from Fotolia.com

Comments

You May Also Like

Related Ads

Featured