Question

I have a question regarding Linux NAT-ing on my own IP address.

Suppose I have an network interface, say eth0. It is given an IP address of 127.0.0.2. Now I apply a NAT rule in Linux saying that:

Any traffic with a source IP of 127.0.0.2 should be changed to a source IP of 192.168.0.2.

What source IP will I see in the packets sent out of eth0? In other words, will the NAT rule be applied to the packets originating from my own machine?

Thanks! Jin

Was it helpful?

Solution

you can use postrouting for the same

iptables -t nat -A POSTROUTING -s 127.0.0.2 -o eth0 -j SNAT --to 192.168.0.2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top