2004-04-05 16:29:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: natd
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nostart nojail
|
2004-04-05 16:29:45 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
. /etc/network.subr
|
|
|
|
|
|
|
|
name="natd"
|
|
|
|
rcvar=`set_rcvar`
|
|
|
|
command="/sbin/${name}"
|
2004-10-22 19:36:03 +00:00
|
|
|
start_precmd="natd_precmd"
|
2004-04-05 16:29:45 +00:00
|
|
|
start_cmd="natd_start"
|
|
|
|
|
2004-10-22 19:36:03 +00:00
|
|
|
natd_precmd()
|
|
|
|
{
|
|
|
|
if ! ${SYSCTL} net.inet.divert > /dev/null 2>&1; then
|
|
|
|
if ! kldload ipdivert; then
|
|
|
|
warn unable to load IPDIVERT module.
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2004-04-05 16:29:45 +00:00
|
|
|
natd_start()
|
|
|
|
{
|
|
|
|
dhcp_list="`list_net_interfaces dhcp`"
|
|
|
|
for ifn in ${dhcp_list}; do
|
|
|
|
case ${natd_interface} in
|
|
|
|
${ifn})
|
|
|
|
natd_flags="$natd_flags -dynamic"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if [ -n "${natd_interface}" ]; then
|
|
|
|
if echo ${natd_interface} | \
|
|
|
|
grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
|
|
|
|
natd_flags="$natd_flags -a ${natd_interface}"
|
|
|
|
else
|
|
|
|
natd_flags="$natd_flags -n ${natd_interface}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo -n ' natd'
|
|
|
|
${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|