Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am needing to set up IPtables to accept traffic on many internal IP's. Is there a wildcard I can use for part of the ip address? For example: 192.168..

Or would there a better alternative?

share|improve this question

closed as off-topic by Jenny D, growse, Nathan C, Dave M, Ward Jul 11 '13 at 13:39

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is about basic unix/linux knowledge and would be better off at – Jenny D Jul 11 '13 at 9:23

iptables does not know wildcards but used the CIDR method. F.e: -s will cover all the hosts from to

You can find more info about CIDR here

share|improve this answer

No wildcard per se, but you can specify a CIDR netmask:

The above would be the CIDR equivalent of the example you gave.

share|improve this answer

Not really a wildcard, you can match IP Adresses by subnets:

Another way is to use ipranges like this: iptables -A INPUT --destination-port 80 -m iprange --src-range From_IP-To_IP -j ACCEPT

There is a second module for --dest-range as well.

share|improve this answer

iptables supports using CIDR notation, so for your example you can use

Unrelatedly, please consider working on your accept-rate.

share|improve this answer

For future googlers, as of current version of iptables 1.4.7

Single port IP Range

iptables -A INPUT -p tcp --dport 8080 -m iprange --src-range -j ACCEPT

Multiple port IP Range

iptables -A INPUT -p tcp -m multiport --dports 21,8080 -m iprange --src-range -j ACCEPT
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.