How to Block Multiple IP Addresses on IPTables

Written by ed stanyer
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Block Multiple IP Addresses on IPTables
Iptables is used to amend the Linux firewall rules. (Thinkstock/Comstock/Getty Images)

Iptables is a UNIX-based application that is used to configure firewall options and rules. It can be used to block IP addresses and ports from accessing the computer. By using a netmask in the rule, entire IP ranges or "blocks" can be denied access. IP ranges can also be blocked by using the Classless Inter-Domain Routing (CIDR) suffix, which is appended to the end of the IP address with a slash notation.

Skill level:
Moderate

Other People Are Reading

Instructions

    Block Using Netmask

  1. 1

    Load up a shell prompt under root access.

  2. 2

    Type "iptables --list" and press "Enter" to view the current firewall rules.

  3. 3

    Type "iptables --A INPUT --s 192.168.1.0/255.255.255.0 --j drop". This denies access to the entire "class C" range 192.168.1.0. This means all traffic from 192.168.1.1 to 192.168.1.254 will be blocked.

    Block using CIDR

  1. 1

    Load up a shell prompt under root access.

  2. 2

    Type "iptables --list" and press "Enter" to view the current firewall rules.

  3. 3

    Type "iptables --A INPUT --s 20.0.0.0/8 --j drop". This denies access to the entire "class A" range of 20.0.0.0. This means all traffic from 20.0.0.1 to 20.255.255.255 will be blocked.

Tips and warnings

  • When using the netmask to block IP address ranges, verify it is valid before entering it. Iptables does not return an error on an invalid netmask, the rule simply does not work.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.