Skip to content

Instantly share code, notes, and snippets.

@fbion
Forked from vitaly/pfdump.sh
Created October 7, 2022 07:23
Show Gist options
  • Save fbion/66a47c22d1889bccf7826a2c7951518d to your computer and use it in GitHub Desktop.
Save fbion/66a47c22d1889bccf7826a2c7951518d to your computer and use it in GitHub Desktop.
script to dump PF status
#!/bin/bash
function pfprint() {
if [ -n "$1" ];then
sudo pfctl -a "$2" -s"$1" 2>/dev/null
else
sudo pfctl -s"$1" 2>/dev/null
fi
}
function print_all() {
local p=$(printf "%-40s" $1)
(
pfprint r "$1" | sed "s,^,r ,"
pfprint n "$1" | sed "s,^,n ,"
pfprint A "$1" | sed "s,^,A ,"
) | sed "s,^,$p,"
for a in `pfprint A "$1"`; do
print_all "$a"
done
}
print_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment