Skip to content

Instantly share code, notes, and snippets.

@jaywax jaywax/flux.ksh
Last active Dec 11, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.