From a21e67079976f01de54537c9730f494891688dfc Mon Sep 17 00:00:00 2001 From: paieer Date: Tue, 9 Aug 2022 10:48:42 +0800 Subject: [PATCH] little fix --- docker.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker.sh b/docker.sh index f964926..3b75e59 100644 --- a/docker.sh +++ b/docker.sh @@ -103,10 +103,12 @@ if [ `echo ${containers} | wc -c` -gt "1" ]; then iptables -t nat -A POSTROUTING -s ${ipaddr}/32 -d ${ipaddr}/32 -p ${dst_proto} -m ${dst_proto} --dport ${dst_port} -j MASQUERADE iptables_opt_src="" - if [ ${src_ip} != "0.0.0.0" ]; then + if [ "${src_ip}" != "0.0.0.0" ]; then iptables_opt_src="-d ${src_ip}/32 " fi - iptables -t nat -A DOCKER ${iptables_opt_src}! -i ${DOCKER_NET_INT} -p ${dst_proto} -m ${dst_proto} --dport ${src_port} -j DNAT --to-destination ${ipaddr}:${dst_port} + if [ ! -z ${src_ip} ]; then + iptables -t nat -A DOCKER ${iptables_opt_src}! -i ${DOCKER_NET_INT} -p ${dst_proto} -m ${dst_proto} --dport ${src_port} -j DNAT --to-destination ${ipaddr}:${dst_port} + fi done fi done