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

So i have this linux router, that has 2000 differents ips. And i want to redirect local source ports between 10001 and 12000 linearly from source addresses in the subnet

So that would means,

localhost:10001 has the source address localhost:10002 ==> ... localhost:10256 ==> ... etc

I know how to do that with 2000 lines of iptables, like this :

iptables -A POSTROUTING -t nat -p tcp --sport 10001 -j SNAT --to-source ... ...

But what i'm after is avoiding doing 2000 lines of iptables and use port range/address range of iptables or somekind of trick that could be possible.

Anyone ?

Many thanks

share|improve this question

Mmmm... I don't think so. You will need 2000 rules. Although you don't have to do them all manually.

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.