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