freebsd-dev/etc/rc.d/ipnat
Mike Makonnen 8cf06adbcb Make ipfilter, ipnat, ipmon, and ipfs behave more like the old rc.
o group them together so they run one right after another
	o use the NetBSD supplied ipfs script instead of tacking
	  it on to the end of ipnat
	o Load the ipl module in ipnat and ipfilter, if it's not already
	  loaded
	o In ipmon and ipnat show a warning if neither ipfilter nor
	  ipnat is enabled or the ipl module is not loaded, and exit

Approved by:	markm (mentor) (implicit)
Tested by:	leafy <leafy@leafy.idv.tw>
2003-04-24 08:20:47 +00:00

66 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: ipnat,v 1.6 2000/09/19 13:04:38 lukem Exp $
# $FreeBSD$
#
# PROVIDE: ipnat
# REQUIRE: ipfilter
# BEFORE: DAEMON netif
# KEYWORD: FreeBSD NetBSD
. /etc/rc.subr
name="ipnat"
rcvar=`set_rcvar`
load_rc_config $name
case ${OSTYPE} in
NetBSD)
ipnat_flags=
ipnat_rules="/etc/ipnat.conf"
ipnat_program="/usr/sbin/ipnat"
;;
esac
start_precmd="ipnat_precmd"
start_cmd="ipnat_start"
stop_cmd="${ipnat_program} -F -C"
reload_cmd="${ipnat_program} -F -C -f ${ipnat_rules}"
extra_commands="reload"
ipnat_precmd()
{
case ${OSTYPE} in
NetBSD)
if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then
echo "Enabling ipfilter for NAT."
/sbin/ipf -E -Fa
fi
return 0
;;
esac
# Make sure ipfilter is loaded before continuing
if ! ${SYSCTL} net.inet.ipf.fr_pass >/dev/null 2>&1; then
if kldload ipl; then
echo 'IP-filter module loaded.'
else
err 1 'IP-filter module failed to load.'
fi
fi
return 0
}
ipnat_start()
{
if [ ! -f ${ipnat_rules} ]; then
echo -n ' NO IPNAT RULES'
return 0
fi
echo -n "Installing NAT rules ... "
/usr/sbin/ipnat -CF -f ${ipnat_rules} ${ipnat_flags}
}
run_rc_command "$1"