2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: ipnat,v 1.6 2000/09/19 13:04:38 lukem Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ipnat
|
2003-04-24 08:20:47 +00:00
|
|
|
# REQUIRE: ipfilter
|
|
|
|
# BEFORE: DAEMON netif
|
2004-03-08 12:25:05 +00:00
|
|
|
# KEYWORD: FreeBSD nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="ipnat"
|
2002-06-13 22:14:37 +00:00
|
|
|
rcvar=`set_rcvar`
|
2003-04-24 08:20:47 +00:00
|
|
|
load_rc_config $name
|
|
|
|
start_precmd="ipnat_precmd"
|
2001-06-16 07:16:14 +00:00
|
|
|
start_cmd="ipnat_start"
|
2003-04-24 08:20:47 +00:00
|
|
|
stop_cmd="${ipnat_program} -F -C"
|
|
|
|
reload_cmd="${ipnat_program} -F -C -f ${ipnat_rules}"
|
2001-06-16 07:16:14 +00:00
|
|
|
extra_commands="reload"
|
|
|
|
|
2002-06-13 22:14:37 +00:00
|
|
|
ipnat_precmd()
|
2001-06-16 07:16:14 +00:00
|
|
|
{
|
2002-06-13 22:14:37 +00:00
|
|
|
# Make sure ipfilter is loaded before continuing
|
2002-10-12 10:31:31 +00:00
|
|
|
if ! ${SYSCTL} net.inet.ipf.fr_pass >/dev/null 2>&1; then
|
2003-04-24 08:20:47 +00:00
|
|
|
if kldload ipl; then
|
2003-04-30 02:54:17 +00:00
|
|
|
info 'IP-filter module loaded.'
|
2003-04-24 08:20:47 +00:00
|
|
|
else
|
|
|
|
err 1 'IP-filter module failed to load.'
|
|
|
|
fi
|
2001-06-16 07:16:14 +00:00
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
ipnat_start()
|
|
|
|
{
|
2003-04-24 08:20:47 +00:00
|
|
|
if [ ! -f ${ipnat_rules} ]; then
|
2003-04-30 02:54:17 +00:00
|
|
|
warn 'NO IPNAT RULES'
|
2003-04-24 08:20:47 +00:00
|
|
|
return 0
|
|
|
|
fi
|
2003-11-03 17:03:01 +00:00
|
|
|
echo "Installing NAT rules."
|
2003-04-24 18:14:52 +00:00
|
|
|
${ipnat_program} -CF -f ${ipnat_rules} ${ipnat_flags}
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run_rc_command "$1"
|