I have a gateway machine with 2 NIC: eth0
with public IP and eth1
with private IP.
On eth0
I have 4 public IP aliased, I wanted to NAT public IP to private IP and I used DNAT to do that uisng iptables.
1.1.1.2 -> 10.10.10.2
1.1.1.3 -> 10.10.10.3
1.1.1.4 -> 10.10.10.4
Rules
-A PREROUTING -d 1.1.1.2 -p tcp -j DNAT --to-destination 10.10.10.2
-A PREROUTING -d 1.1.1.3 -p tcp -j DNAT --to-destination 10.10.10.3
-A PREROUTING -d 1.1.1.4 -p tcp -j DNAT --to-destination 10.10.10.4
and now I am able to reach internal IP with DNAT, but not able to connect with external network from this private IP.
How can I achieve that? Can SNAT be done for multiple IPS?