2002-06-13 22:14:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ipfw
|
2005-10-28 16:07:52 +00:00
|
|
|
# REQUIRE: ppp
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: NETWORKING
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
2003-07-27 20:34:30 +00:00
|
|
|
. /etc/network.subr
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
name="ipfw"
|
|
|
|
rcvar="firewall_enable"
|
|
|
|
start_cmd="ipfw_start"
|
|
|
|
start_precmd="ipfw_precmd"
|
2003-03-30 15:52:18 +00:00
|
|
|
stop_cmd="ipfw_stop"
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
ipfw_precmd()
|
|
|
|
{
|
2002-10-12 10:31:31 +00:00
|
|
|
if ! ${SYSCTL} net.inet.ip.fw.enable > /dev/null 2>&1; then
|
|
|
|
if ! kldload ipfw; then
|
2002-06-13 22:14:37 +00:00
|
|
|
warn unable to load firewall module.
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
ipfw_start()
|
|
|
|
{
|
|
|
|
# set the firewall rules script if none was specified
|
|
|
|
[ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall
|
|
|
|
|
|
|
|
if [ -r "${firewall_script}" ]; then
|
2005-03-16 08:47:48 +00:00
|
|
|
echo -n 'Starting divert daemons:'
|
2004-04-28 13:20:15 +00:00
|
|
|
if [ -f /etc/rc.d/natd ] ; then
|
|
|
|
/etc/rc.d/natd start
|
|
|
|
fi
|
2005-03-16 08:47:48 +00:00
|
|
|
. "${firewall_script}"
|
|
|
|
echo -n 'Firewall rules loaded'
|
2002-06-13 22:14:37 +00:00
|
|
|
elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
|
|
|
|
echo 'Warning: kernel has firewall functionality, but' \
|
|
|
|
' firewall rules are not enabled.'
|
|
|
|
echo ' All ip services are disabled.'
|
|
|
|
fi
|
|
|
|
echo '.'
|
|
|
|
|
|
|
|
# Firewall logging
|
|
|
|
#
|
2003-03-30 15:52:18 +00:00
|
|
|
if checkyesno firewall_logging; then
|
|
|
|
echo 'Firewall logging enabled'
|
|
|
|
sysctl net.inet.ip.fw.verbose=1 >/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enable the firewall
|
|
|
|
#
|
|
|
|
${SYSCTL_W} net.inet.ip.fw.enable=1
|
|
|
|
}
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2003-03-30 15:52:18 +00:00
|
|
|
ipfw_stop()
|
|
|
|
{
|
|
|
|
# Disable the firewall
|
|
|
|
#
|
|
|
|
${SYSCTL_W} net.inet.ip.fw.enable=0
|
2004-04-28 13:20:15 +00:00
|
|
|
if [ -f /etc/rc.d/natd ] ; then
|
|
|
|
/etc/rc.d/natd stop
|
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|