2004-03-23 22:30:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: pf
|
2009-06-26 01:04:50 +00:00
|
|
|
# REQUIRE: FILESYSTEMS netif pflog pfsync
|
2005-10-02 19:12:42 +00:00
|
|
|
# BEFORE: routing
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2004-03-23 22:30:15 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="pf"
|
2012-01-14 02:18:41 +00:00
|
|
|
rcvar="pf_enable"
|
2004-03-23 22:30:15 +00:00
|
|
|
load_rc_config $name
|
|
|
|
start_cmd="pf_start"
|
|
|
|
stop_cmd="pf_stop"
|
2004-10-25 08:12:28 +00:00
|
|
|
check_cmd="pf_check"
|
2004-03-23 22:30:15 +00:00
|
|
|
reload_cmd="pf_reload"
|
|
|
|
resync_cmd="pf_resync"
|
|
|
|
status_cmd="pf_status"
|
2011-05-17 07:40:13 +00:00
|
|
|
extra_commands="check reload resync"
|
2005-10-02 19:17:49 +00:00
|
|
|
required_files="$pf_rules"
|
2006-12-31 10:37:18 +00:00
|
|
|
required_modules="pf"
|
2004-03-23 22:30:15 +00:00
|
|
|
|
|
|
|
pf_start()
|
|
|
|
{
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo -n 'Enabling pf'
|
2006-06-05 03:47:14 +00:00
|
|
|
$pf_program -F all > /dev/null 2>&1
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -f "$pf_rules" $pf_flags
|
|
|
|
if ! $pf_program -s info | grep -q "Enabled" ; then
|
2010-12-17 09:38:55 +00:00
|
|
|
$pf_program -eq
|
2004-06-23 01:42:06 +00:00
|
|
|
fi
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo '.'
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pf_stop()
|
|
|
|
{
|
2005-10-02 19:17:49 +00:00
|
|
|
if $pf_program -s info | grep -q "Enabled" ; then
|
2009-10-10 22:17:03 +00:00
|
|
|
echo -n 'Disabling pf'
|
2010-12-17 09:38:55 +00:00
|
|
|
$pf_program -dq
|
2009-10-10 22:17:03 +00:00
|
|
|
echo '.'
|
2004-03-23 22:30:15 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-10-25 08:12:28 +00:00
|
|
|
pf_check()
|
|
|
|
{
|
|
|
|
echo "Checking pf rules."
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -n -f "$pf_rules"
|
2004-10-25 08:12:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 22:30:15 +00:00
|
|
|
pf_reload()
|
|
|
|
{
|
|
|
|
echo "Reloading pf rules."
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -n -f "$pf_rules" || return 1
|
2005-04-04 23:06:10 +00:00
|
|
|
# Flush everything but existing state entries that way when
|
|
|
|
# rules are read in, it doesn't break established connections.
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp > /dev/null 2>&1
|
|
|
|
$pf_program -f "$pf_rules" $pf_flags
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pf_resync()
|
|
|
|
{
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -f "$pf_rules" $pf_flags
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pf_status()
|
|
|
|
{
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -s info
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run_rc_command "$1"
|