2004-03-23 22:30:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: pf
|
2009-06-26 02:04:50 +01:00
|
|
|
# REQUIRE: FILESYSTEMS netif pflog pfsync
|
2005-10-02 20:12:42 +01:00
|
|
|
# BEFORE: routing
|
2004-10-07 14:55:26 +01: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 09:12:28 +01: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 08:40:13 +01:00
|
|
|
extra_commands="check reload resync"
|
2005-10-02 20:17:49 +01: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 23:17:03 +01:00
|
|
|
check_startmsgs && echo -n 'Enabling pf'
|
2006-06-05 04:47:14 +01:00
|
|
|
$pf_program -F all > /dev/null 2>&1
|
2005-10-02 20:17:49 +01: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 02:42:06 +01:00
|
|
|
fi
|
2009-10-10 23:17:03 +01:00
|
|
|
check_startmsgs && echo '.'
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pf_stop()
|
|
|
|
{
|
2005-10-02 20:17:49 +01:00
|
|
|
if $pf_program -s info | grep -q "Enabled" ; then
|
2009-10-10 23:17:03 +01:00
|
|
|
echo -n 'Disabling pf'
|
2010-12-17 09:38:55 +00:00
|
|
|
$pf_program -dq
|
2009-10-10 23:17:03 +01:00
|
|
|
echo '.'
|
2004-03-23 22:30:15 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-10-25 09:12:28 +01:00
|
|
|
pf_check()
|
|
|
|
{
|
|
|
|
echo "Checking pf rules."
|
2005-10-02 20:17:49 +01:00
|
|
|
$pf_program -n -f "$pf_rules"
|
2004-10-25 09:12:28 +01:00
|
|
|
}
|
|
|
|
|
2004-03-23 22:30:15 +00:00
|
|
|
pf_reload()
|
|
|
|
{
|
|
|
|
echo "Reloading pf rules."
|
2005-10-02 20:17:49 +01:00
|
|
|
$pf_program -n -f "$pf_rules" || return 1
|
2005-04-05 00:06:10 +01:00
|
|
|
# Flush everything but existing state entries that way when
|
|
|
|
# rules are read in, it doesn't break established connections.
|
2005-10-02 20:17:49 +01: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 20:17:49 +01:00
|
|
|
$pf_program -f "$pf_rules" $pf_flags
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pf_status()
|
|
|
|
{
|
2005-10-02 20:17:49 +01:00
|
|
|
$pf_program -s info
|
2004-03-23 22:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run_rc_command "$1"
|