Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

4 Answers

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

You can find more info about CIDR here

share|improve this answer

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

192.168.0.0/16 192.168.1.0/24 192.168.2.0/25

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

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

192.168.0.0/16

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

share|improve this answer

iptables supports using CIDR notation, so for your example you can use 192.168.0.0/16.

Unrelatedly, please consider working on your accept-rate.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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