1

Guys i am having an issue with NAT on centos. In my LAB Centos is configured as a router. I want to run my local system (example: 192.168.1.45) apache server on live IP (example 112.100.4.34).

This is already done by another user but i am unable to do it.

1 Answer 1

1

this can be done via post-routing table and masquerade:

 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

previous rule will nat all traffic trough the eth0 interface and change the source address (if that is the interface with the public ip address.) if you want to nat a single ip:

 iptables -t nat -A POSTROUTING -src 192.168.1.45 -o eth0 -j SNAT --to 112.100.4.34

If you want to persistent the previously rule add the rule removing iptables prefix in to /etc/sysconfig/iptables file of your centos.

To have a detail of the iptables rules take a read here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .