Last active
March 15, 2023 02:42
-
-
Save jaywax/78fa3a3a610bf87f5e6a680cc203eb59 to your computer and use it in GitHub Desktop.
Ksh script to play with pf's anchor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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