Netfilter NAT

with iptables front-end

tested with artful

echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
sysctl -p
#echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o FACING-DEVICE -s INTERNAL/CIDR -j SNAT --to-source FACING-IP

with firewalld front-end

tested with RHEL/CentOS 7

Enable IP forwarding,

echo "net.ipv4.ip_forward = 1" > /etc/sysctl.d/ip_forward.conf
sysctl -p

Enable NAT,

firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o EXTERNAL_NETIF -j MASQUERADE -s INTERNAL_IP/PREFIX
firewall-cmd --permanent --direct --passthrough ipv4 -I FORWARD -i INTERNAL_NETIF -j ACCEPT
firewall-cmd --reload

Last update: 2018-10-13 | home | html | css