summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Gerus <arachnist@i.am-a.cat>2013-08-25 23:30:41 +0200
committerRobert Gerus <arachnist@i.am-a.cat>2013-08-25 23:30:41 +0200
commit3ddcb48412ce9be9cbb4d0213d894a517b23ef27 (patch)
tree845f4faa1f81b745a51b6a46d2fabfc105853bcb
parent7ba6a0b67c6395fb66e89dac716ad77c80751b9c (diff)
downloadhs-fw-3ddcb48412ce9be9cbb4d0213d894a517b23ef27.tar.gz
hs-fw-3ddcb48412ce9be9cbb4d0213d894a517b23ef27.tar.bz2
hs-fw-3ddcb48412ce9be9cbb4d0213d894a517b23ef27.tar.xz
hs-fw-3ddcb48412ce9be9cbb4d0213d894a517b23ef27.zip
Add a utility for easier handling of pf logging facilities.
-rwxr-xr-xutils/fwlog68
1 files changed, 68 insertions, 0 deletions
diff --git a/utils/fwlog b/utils/fwlog
new file mode 100755
index 0000000..77fd127
--- /dev/null
+++ b/utils/fwlog
@@ -0,0 +1,68 @@
+#!/usr/local/bin/bash
+
+set -o errexit
+set -o pipefail
+set -o nounset
+
+PFCTL="/sbin/pfctl"
+
+add() {
+ ${PFCTL} -t loghosts -Tadd ${1}
+}
+
+del() {
+ ${PFCTL} -t loghosts -Tdel ${1}
+}
+
+show() {
+ ${PFCTL} -t loghosts -Tshow
+}
+
+log() {
+ tcpdump -n -e -ttt -i pflog0
+}
+
+usage() {
+ echo "${0} <action> [<argument>]"
+ cat << EOF
+ where <action> is one of:
+ add - add an address to loghosts table
+ del - remove an address from loghosts table
+ show|list - list contents of loghosts table
+ log|trace|follow - realtime display of logged connections
+ where <argument> is applicable for following actions:
+ add - ip address or FQDN
+ del - ip address or FQDN
+EOF
+}
+
+# poor getopts replacement. i'm too lazy to learn getopts
+while [[ $# -gt 0 ]]; do
+ case ${1} in
+ add)
+ add ${2}
+ shift 2
+ ;;
+ del)
+ del ${2}
+ shift 2
+ ;;
+ show|list)
+ show
+ shift 2
+ ;;
+ log|trace|follow)
+ log
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "unknown argument"
+ exit 1
+ ;;
+ esac
+done
+