diff --git a/trafficjam-functions.sh b/trafficjam-functions.sh index 95cf971..5c4bb48 100755 --- a/trafficjam-functions.sh +++ b/trafficjam-functions.sh @@ -190,11 +190,17 @@ function get_local_load_balancer_ip() { fi } -function iptables_tj() { +function detect_iptables_version() { + if iptables-nft -L DOCKER-USER &> /dev/null; then + IPTABLES_CMD=iptables-nft + fi +} + +function iptables_tj() { if [[ "$NETWORK_DRIVER" == "overlay" ]]; then - nsenter --net="$NETNS" -- iptables "$@" + nsenter --net="$NETNS" -- $IPTABLES_CMD "$@" else - iptables "$@" + $IPTABLES_CMD "$@" fi } diff --git a/trafficjam.sh b/trafficjam.sh index 92576ea..1ef553c 100755 --- a/trafficjam.sh +++ b/trafficjam.sh @@ -35,6 +35,11 @@ TJINSTANCE=$(echo -n "$NETWORK $WHITELIST_FILTER" | gzip -c | tail -c8 | hexdump . trafficjam-functions.sh ERRCOUNT=0 + +IPTABLES_CMD=iptables + +detect_iptables_version + if [[ -n "$SWARM_DAEMON" ]]; then remove_service