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"
|
2008-01-27 15:15:12 +00:00
|
|
|
start_precmd="ipfw_prestart"
|
2003-03-30 15:52:18 +00:00
|
|
|
stop_cmd="ipfw_stop"
|
2006-12-31 10:37:18 +00:00
|
|
|
required_modules="ipfw"
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2008-01-27 15:15:12 +00:00
|
|
|
ipfw_prestart()
|
|
|
|
{
|
|
|
|
if checkyesno dummynet_enable; then
|
|
|
|
required_modules="$required_modules dummynet"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2002-06-13 22:14:37 +00:00
|
|
|
ipfw_start()
|
|
|
|
{
|
|
|
|
# set the firewall rules script if none was specified
|
|
|
|
[ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall
|
|
|
|
|
|
|
|
if [ -r "${firewall_script}" ]; then
|
2004-04-28 13:20:15 +00:00
|
|
|
if [ -f /etc/rc.d/natd ] ; then
|
2008-01-26 14:02:19 +00:00
|
|
|
/etc/rc.d/natd quietstart
|
2004-04-28 13:20:15 +00:00
|
|
|
fi
|
2007-04-02 15:38:53 +00:00
|
|
|
/bin/sh "${firewall_script}"
|
2006-07-25 17:28:18 +00:00
|
|
|
echo 'Firewall rules loaded.'
|
2006-02-26 16:45:29 +00:00
|
|
|
elif [ "`ipfw list 65535`" = "65535 deny ip from any to any" ]; then
|
2002-06-13 22:14:37 +00:00
|
|
|
echo 'Warning: kernel has firewall functionality, but' \
|
|
|
|
' firewall rules are not enabled.'
|
|
|
|
echo ' All ip services are disabled.'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Firewall logging
|
|
|
|
#
|
2003-03-30 15:52:18 +00:00
|
|
|
if checkyesno firewall_logging; then
|
2006-07-25 17:28:18 +00:00
|
|
|
echo 'Firewall logging enabled.'
|
2003-03-30 15:52:18 +00:00
|
|
|
sysctl net.inet.ip.fw.verbose=1 >/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enable the firewall
|
|
|
|
#
|
2008-07-05 15:27:39 +00:00
|
|
|
if ! ${SYSCTL_W} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then
|
|
|
|
warn "failed to enable firewall"
|
|
|
|
fi
|
2003-03-30 15:52:18 +00:00
|
|
|
}
|
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
|
2008-01-26 14:02:19 +00:00
|
|
|
/etc/rc.d/natd quietstop
|
2004-04-28 13:20:15 +00:00
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|