Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 192.168.0.0/21

So that would means,

localhost:10001 has the source address 192.168.0.1 localhost:10002 ==> 192.168.0.2 ... localhost:10256 ==> 192.168.1.1 ... 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 192.168.0.1 ... ...

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

1 Answer 1

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

 
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.