Use -j MASQUERADE
(extraído dos documentos do CentOS ):
To allow LAN nodes with private IP addresses to communicate with external public networks, configure the firewall for IP masquerading, which masks requests from LAN nodes with the IP address of the firewall's external device (in this case,
eth0
):[root@myServer ~ ] # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
This rule uses the NAT packet matching table (
-t nat
) and specifies the built-inPOSTROUTING
chain for NAT (-A POSTROUTING
) on the firewall's external networking device (-o eth0
).
POSTROUTING
allows packets to be altered as they are leaving the firewall's external device.The
-j MASQUERADE
target is specified to mask the private IP address of a node with the external IP address of the firewall/gateway.
Ele foi criado para uplinks que não possuem endereços IP estáticos.