User Tools

Site Tools


nat

Enable IP Forwarding First

sed -i 's/.*net\.ipv4\.ip_forward.*/net.ipv4.ip_forward = 1/' /etc/sysctl.conf
sysctl -p

NAT using iptables

iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -j SNAT --to-source <IP>

Another Way (OpenVZ won't work this way)

iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -j MASQUERADE

Or if you want to MASQUERADE all interfaces:

iptables -t nat -A POSTROUTING ! -o lo -j MASQUERADE
nat.txt · Last modified: 2017/01/05 06:21 by felixonmars