2004-04-05 16:29:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: natd
|
2017-07-08 09:28:31 +00:00
|
|
|
# KEYWORD: nostart nojailvnet
|
2004-04-05 16:29:45 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
. /etc/network.subr
|
|
|
|
|
|
|
|
name="natd"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Network Address Translation daemon"
|
2012-01-14 02:18:41 +00:00
|
|
|
rcvar="natd_enable"
|
2004-04-05 16:29:45 +00:00
|
|
|
command="/sbin/${name}"
|
2006-07-25 17:25:44 +00:00
|
|
|
pidfile="/var/run/${name}.pid"
|
2004-10-22 19:36:03 +00:00
|
|
|
start_precmd="natd_precmd"
|
2006-12-31 10:37:18 +00:00
|
|
|
required_modules="ipdivert"
|
2004-04-05 16:29:45 +00:00
|
|
|
|
2004-10-22 19:36:03 +00:00
|
|
|
natd_precmd()
|
|
|
|
{
|
2004-04-05 16:29:45 +00:00
|
|
|
if [ -n "${natd_interface}" ]; then
|
2006-07-25 17:25:44 +00:00
|
|
|
dhcp_list="`list_net_interfaces dhcp`"
|
|
|
|
for ifn in ${dhcp_list}; do
|
|
|
|
case "${natd_interface}" in
|
|
|
|
${ifn})
|
|
|
|
rc_flags="$rc_flags -dynamic"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if echo "${natd_interface}" | \
|
|
|
|
grep -q -E '^[0-9]+(\.[0-9]+){0,3}$'; then
|
|
|
|
rc_flags="$rc_flags -a ${natd_interface}"
|
2004-04-05 16:29:45 +00:00
|
|
|
else
|
2006-07-25 17:25:44 +00:00
|
|
|
rc_flags="$rc_flags -n ${natd_interface}"
|
2004-04-05 16:29:45 +00:00
|
|
|
fi
|
|
|
|
fi
|
2006-07-25 17:25:44 +00:00
|
|
|
|
|
|
|
return 0
|
2004-04-05 16:29:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|