mirror of
https://github.com/juliengk/csf-post-docker.git
synced 2023-10-10 13:37:41 +02:00
Fixed the "iptables: Chain already exists" error
This commit is contained in:
parent
808685f2f1
commit
a9eb227755
@ -1 +1,5 @@
|
|||||||
# ConfigServer Security & Firewall (CSF) - Docker
|
# ConfigServer Security & Firewall (CSF) - Docker
|
||||||
|
|
||||||
|
Install:
|
||||||
|
|
||||||
|
cp csfpost.sh /usr/local/csf/bin/csfpost.sh
|
||||||
|
15
csfpost.sh
15
csfpost.sh
@ -1,8 +1,23 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
chain_exists()
|
||||||
|
{
|
||||||
|
[ $# -lt 1 -o $# -gt 2 ] && {
|
||||||
|
echo "Usage: chain_exists <chain_name> [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_INT="docker0"
|
||||||
DOCKER_NETWORK="172.17.0.0/16"
|
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 -N DOCKER
|
||||||
iptables -t nat -N DOCKER
|
iptables -t nat -N DOCKER
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user