Skip to content

Instantly share code, notes, and snippets.

@nwg
Forked from vitaly/pfdump.sh
Created June 26, 2021 05:32
Show Gist options
  • Save nwg/e5b41ae2736504dcf13fe600e117e824 to your computer and use it in GitHub Desktop.
Save nwg/e5b41ae2736504dcf13fe600e117e824 to your computer and use it in GitHub Desktop.
script to dump PF status
#!/bin/bash
function pfprint() {
if [ -n "$2" ];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