From 394edce8fab3d8b3d589e7b1a2f8306900c89887 Mon Sep 17 00:00:00 2001 From: x p k Date: Wed, 27 Mar 2019 10:54:26 +0800 Subject: [PATCH] new: iptables script for Incapsula --- sh/incapsula-iptables.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sh/incapsula-iptables.sh diff --git a/sh/incapsula-iptables.sh b/sh/incapsula-iptables.sh new file mode 100644 index 0000000..c669aa3 --- /dev/null +++ b/sh/incapsula-iptables.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# script for populating iptables with incapsula IPs +# to use this, send http and https traffic to the incapsula chain +# then schedule a daily task which runs this script + +iptables -N incapsula +iptables -F incapsula +curl -k -s --data "resp_format=json" https://my.incapsula.com/api/integration/v1/ips | jq -r '.ipRanges | @csv' | tr ',' '\n' | tr -d \" | while read i; do +iptables -A incapsula -s $i -j ACCEPT +done +iptables -A incapsula -j DROP