2

I am trying to make destination NAT from one range (192.168.2.0/24) to corresponding ip addresses in another range (192.168.1.0/24).

I have managed to do this ip by ip

iptables -t nat -A PREROUTING -i ppp0 -d 192.168.2.1 -p all -j DNAT --to-destination 192.168.1.1
iptables -t nat -A PREROUTING -i ppp0 -d 192.168.2.2 -p all -j DNAT --to-destination 192.168.1.2
iptables -t nat -A PREROUTING -i ppp0 -d 192.168.2.3 -p all -j DNAT --to-destination 192.168.1.3
etc..

Is any way that I can specify source & destination range in single line ?

Thanks!

4

You should try this:

iptables -t nat -A PREROUTING -i ppp0 -d 192.168.2.0/24 -j NETMAP --to 192.168.1.0/24


The following references may help you:

Iptables massive 1:1 NAT

http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO-4.html

| improve this answer | |

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.