How to add multiple IP's at once to iptables?

Discussion in 'Site & Server Administration' started by warman2442, Jan 10, 2008.

  1. #1
    Hey

    I was wondering how can i add multiple ip addresses to ip tables instead of having to block one by one.

    Thanks

    Tyler
     
    warman2442, Jan 10, 2008 IP
  2. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #2
    I don't know of any extension that supports multiple comma-separated values for ip addresses (there is one for ports), but you have 2 options which might help.

    You can either specify a network address in various forms (such as 192.168.0.0/24 or 10.0.0.0/255.0.0.0) or use the iprange extension. You can use the iprange extension like this:

    iptables -I INPUT -m iprange --src-range 192.168.0.100-192.168.0.200 -p tcp --dport 22 -j LOG
    Code (markup):
     
    boltok, Jan 11, 2008 IP