Hi all,<br> I have been attempting to use iptables to NAT internal IPs to an external IP without success. I have experience with iptables, but mainly on how to close or open specific ports. Nat has proved a little challenging and thats why i am seeking assistance.
<br> Lets say I have an internal IPs as <a href="http://10.0.0.0/24">10.0.0.0/24</a> and need all those IP natted to an external IP <a href="http://192.168.2.1">192.168.2.1</a>. This is what I have attempted in my quest to find a solution.
<br>/sbin/iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to <a href="http://192.168.2.1">192.168.2.1</a><br><br>when I check the firewall status, I notice this table insertion<br>Chain POSTROUTING (policy ACCEPT)<br>target     prot opt source               destination         
<br>SNAT       all  --  <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>           to:<a href="http://192.168.2.1">192.168.2.1</a><br><br> To be frank, I expected <a href="http://192.168.2.1">
192.168.2.1</a> to be the destination. The way the details are presented is confusing, IMO. Whats however puzzling is this command is rejected when I attempt to make it persistant as seen below. <br>vi /etec/sysconfig/iptables
<br>Just before the line below, I inserted the second command<br>REJECT     all  --  <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>           reject-with icmp-host-prohibited<br>
-A POSTROUTING -o eth0 -j SNAT --to <a href="http://192.168.2.1">192.168.2.1</a><br><br>This however don't work as iptable throws an error message and fails to come up.<br>Now the question is, what is the proper way of doing a nat throw a linux box? I have enabled IP forwarding by the way.
<br><br>Thanks in advance<br>William<br>