Modify NAT Iptables rules at Linux server

Check current configuration. Maybe rule already present?

#iptables -t nat -L -n

Save current configuration to file.

#iptables-save > /etc/sysconfig/some_file_you_want

Edit configuration file.

#vi /etc/sysconfig/some_file_you_want

For Destination NAT add record to PREROUTING section.

Sample: All incoming traffic to IP 10.10.10.10 and port tcp/443 NAT-ed to IP 192.168.0.10 port tcp/10000

-A PREROUTING -d 65.87.230.18/32 -p tcp -m tcp –dport 443 -j DNAT –to-destination 192.168.96.140:10000

For Source NAT add record to POSTROUTING section.

Sample: All outgoing traffic “to world“ and port tcp/25 will be NAT-ed with source address 10.10.10.10

-A POSTROUTING -s 192.168.0.10/32 -o eth0 -p tcp -m tcp --dport 25 -j SNAT --to-source 10.10.10.10

Check you made correct records in correct sections.

Save file.

Apply iptables configuration to server.

iptables-restore < /etc/sysconfig/some_file_you_want