#!/bin/bash
IF=ppp0
case "$1" in
--start)
/usr/sbin/sysctl -w net.inet.ip.forwarding=1
/usr/sbin/natd -clamp_mss -dynamic -unregistered_only -interface $IF
/sbin/ipfw add divert natd all from any to any via $IF
/usr/sbin/named -c /etc/named.conf
;;
--stop)
killall -9 natd
killall -9 named
/usr/sbin/sysctl -w net.inet.ip.forwarding=0
echo y |/sbin/ipfw flush
;;
--restart)
"$0" --stop && "$0" --start
;;
*)
echo "Usage: $0 {--start|--stop|--restart}"
exit 1
esac