]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Script to randomly block connections
authorAlan T. DeKok <aland@freeradius.org>
Thu, 6 Apr 2023 19:31:35 +0000 (15:31 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 6 Apr 2023 19:34:36 +0000 (15:34 -0400)
src/tests/tls/block.sh [new file with mode: 0755]

diff --git a/src/tests/tls/block.sh b/src/tests/tls/block.sh
new file mode 100755 (executable)
index 0000000..f397eaa
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Simple script blocking requests from proxy to home server
+#
+#  This works only on Linux.  It can be used to create random networking issues.
+
+if [ $UID -ne 0 ]; then
+        echo "Only 'root' can modify 'iptables' rules"
+        exit 1
+fi
+
+MAXWAIT=5
+while true; do
+        _wait="$((RANDOM % MAXWAIT))"
+
+        echo "(*) Blocking the port 2083 for ${_wait}s"
+        iptables -A INPUT -p tcp --dport 2083 -j REJECT
+        sleep $_wait
+
+        echo "(*) Allowing the port 2083 for ${_wait}s"
+        iptables -D INPUT -p tcp --dport 2083 -j REJECT
+        sleep $_wait
+done