SNAT

Masquerading, as we have previously discussed it, is just a special case of source NAT. If you happen to have a public, static IP, you don't want masquerading—what you want is source network address translation (SNAT). You'll want to use SNAT instead of masquerading where possible for some of the features SNAT brings, including mapping your hosts to multiple IP addresses.

Looking at a few examples and their explanations might help your understanding:

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 209.127.112.150

The preceding line says you want to use the NAT table (-t nat) and append to the POSTROUTING chain. You're going to use the outgoing interface eth0 (this is the Internet- connected interface) and change the source address of ...

Get Special Edition Using Linux®, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.