diff --git a/README.md b/README.md index 7f99c71..916d466 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ # ConfigServer Security & Firewall (CSF) - Docker + +Install: + +cp csfpost.sh /usr/local/csf/bin/csfpost.sh diff --git a/csfpost.sh b/csfpost.sh index 839be05..c7640c2 100644 --- a/csfpost.sh +++ b/csfpost.sh @@ -1,8 +1,23 @@ #!/bin/bash +chain_exists() +{ + [ $# -lt 1 -o $# -gt 2 ] && { + echo "Usage: chain_exists [table]" >&2 + return 1 + } + local chain_name="$1" ; shift + [ $# -eq 1 ] && local table="--table $1" + iptables $table -n --list "$chain_name" >/dev/null 2>&1 +} + DOCKER_INT="docker0" DOCKER_NETWORK="172.17.0.0/16" +iptables-save | grep -v -- '-j DOCKER' | iptables-restore +chain_exists DOCKER && iptables -X DOCKER +chain_exists DOCKER nat && iptables -t nat -X DOCKER + iptables -N DOCKER iptables -t nat -N DOCKER