I'm looking for a way how to nat 2 or more inner IPs (in my case xen doms) to one outer IP.
I tried to use
iptables -t nat -A PREROUTING -d 126.96.36.199 -j DNAT --to 188.8.131.52 --to 184.108.40.206
iptables -t nat -A POSTROUTING -s 220.127.116.11 -j SNAT --to 18.104.22.168
iptables -t nat -A POSTROUTING -s 22.214.171.124 -j SNAT --to 126.96.36.199
And got an error:
iptables v1.4.14: DNAT: Multiple --to-destination not supported
Try `iptables -h' or 'iptables --help' for more information.
I found this in the manpage:
Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges anymore.
So my question is: Why is it not possible anymore and is there a workaround? Maybe I should use an other method I don't know yet?
The idea is to use the system like a router, so I have one address but multiple users behind. The problem is I don't know which connection reffers to a user (for example
188.8.131.52). But I know, they all have different ports open for incomming traffic.
So my solution (for DNAT) would be to nat all incoming connections to all users and filter all unused ports, so the connection goes to one single user. For outgoing traffic I would use
iptables -A FORWARD -i eth0 -d 184.108.40.206 -m state --state ESTABLISHED,RELATED -j ACCEPT