Skip to content

Instantly share code, notes, and snippets.

@jaywax
Last active March 15, 2023 02:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaywax/78fa3a3a610bf87f5e6a680cc203eb59 to your computer and use it in GitHub Desktop.
Save jaywax/78fa3a3a610bf87f5e6a680cc203eb59 to your computer and use it in GitHub Desktop.
Ksh script to play with pf's anchor
#!/bin/ksh
######################################################################################################################################
#
# Author : jaywax.2.bourbon@gmail.com - jaywax
# Date : 11/12/2018
# Version : V2.1
# Goal : Used by domogik installation to play with pf anchor.
# $1 : anchor : tab_enfants_all_wif | tel_enfants_all_wif | pc_jeux_wif | obiwan_web_wif | tab_college_all_wif | freebox_4k_all_bad
# $2 : action : on | off
######################################################################################################################################
PFCTL=/sbin/pfctl
ECHO=/bin/echo
ANCHOR=$1
ACTION=$2
case $2 in
on)
$ECHO "pass in quick" | $PFCTL -a "$1/tcp" -f -
$ECHO "pass in quick" | $PFCTL -a "$1/udp" -f -
;;
off)
case $1 in
tab_enfants_all_wif)
HOSTS="172.16.41.9 172.16.41.10"
;;
tab_enfants_all_wif)
HOSTS="172.16.41.13"
;;
pc_jeux_wif)
HOSTS="172.16.41.8 172.16.41.14"
;;
obiwan_web_wif)
HOSTS="172.16.41.14"
;;
tab_college_all_wif)
HOSTS="172.16.41.15"
;;
tab_college_all_wif)
HOSTS="172.16.43.4"
;;
esac
$ECHO "block log quick" | $PFCTL -a "$1/tcp" -f -
$ECHO "block log quick" | $PFCTL -a "$1/udp" -f -
for host in $HOSTS; do
$PFCTL -k $host
$PFCTL -k 0.0.0.0/0 -k $host
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment