SNAT pentru IP dinamic folosind iptables - PPPoE sau DHCP
#!/bin/sh WANIF="ppp0" LANIF="eth0" INTERNALNET="192.168.0.0/24" IFCONFIG=/sbin/ifconfig IPTABLES=/usr/sbin/iptables GREP=/bin/grep AWK=/bin/awk
Determinam adresa IP externa automat:
WANIP="`$IFCONFIG $WANIF | $GREP 'inet addr' | $AWK '{print $2}' | sed -e 's/.*://'`"
Se face SNAT la toate IP-urile din reteaua locala prin IP-ul extern
$IPTABLES -t nat -A POSTROUTING -s $INTERNALNET -j SNAT --to $WANIP
Gata