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


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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