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 22.214.171.124 -j DNAT --to 126.96.36.199 --to 188.8.131.52
iptables -t nat -A POSTROUTING -s 184.108.40.206 -j SNAT --to 220.127.116.11
iptables -t nat -A POSTROUTING -s 18.104.22.168 -j SNAT --to 22.214.171.124
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
126.96.36.199). 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 188.8.131.52 -m state --state ESTABLISHED,RELATED -j ACCEPT