Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
iptables -I PREROUTING -t nat -p udp -s --dport 53 -j DNAT --to-destination

Instead of only rerouting traffic from, I'd like to reroute traffic from all ips, 192.168.0.*, possible?

share|improve this question
All to the same destination? Try replacing -s with -s – Zoredache Sep 18 '13 at 0:07
Works, thank you. – Gabe Sep 18 '13 at 0:21

Just wanted to add to @Zoredache comment (Which is also an answer)

Extract of the Command iptables in relation to -s flag

--source -s [!] address[/mask]

So what @Zoredache has suggested works by working on the subnet mask short hand

To break down -s we need to look at the subnet mask it represents:

Now this doesn't really give us any indication of how it's represented as the number 24 until we look at the binary representation of the subnet mask:


Now a quick count will show that the first 24 binary switches are set to 1 this is why it's represented as /24

So what we have told the iptables command is that we want the source to be the first 256 ( IP addresses starting at to be declared as a source in this command

Another example would be I want the first 65,536 IP addresses starting at to be the source

So the command would be -s this is subnet mask (Binary is 11111111.11111111.00000000.00000000) and this will declare through as the source addresses

share|improve this answer

Your Answer


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.