1
0
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:
Frantzcy Paisible 2015-08-17 07:13:50 -04:00
parent 808685f2f1
commit a9eb227755
2 changed files with 19 additions and 0 deletions

View File

@ -1 +1,5 @@
# ConfigServer Security & Firewall (CSF) - Docker
Install:
cp csfpost.sh /usr/local/csf/bin/csfpost.sh

View File

@ -1,8 +1,23 @@
#!/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_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