2004-03-23 22:30:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: pf
|
2005-10-02 19:12:42 +00:00
|
|
|
# REQUIRE: root mountcritlocal netif pflog pfsync
|
|
|
|
# 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"
|
|
|
|
rcvar=`set_rcvar`
|
|
|
|
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"
|
2005-11-10 10:40:15 +00:00
|
|
|
extra_commands="check reload resync status"
|
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()
|
|
|
|
{
|
|
|
|
echo "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
|
|
|
|
$pf_program -e
|
2004-06-23 01:42:06 +00:00
|
|
|
fi
|
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
|
2004-03-23 22:30:15 +00:00
|
|
|
echo "Disabling pf."
|
2005-10-02 19:17:49 +00:00
|
|
|
$pf_program -d
|
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"
|