浏览代码

更新 iptables 命令防止重复添加

zjcqoo 6 年之前
父节点
当前提交
410af95594
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      setup-ipset.sh

+ 6 - 2
setup-ipset.sh

@@ -1,11 +1,15 @@
 #
 #
-# 该脚本用于禁止 jsporxy 用户访问内网(针对 TCP)
+# 该脚本用于禁止 jsporxy 用户访问内网,防止 SSRF 攻击
 # 需要 root 权限运行,依赖 ipset 命令
 # 需要 root 权限运行,依赖 ipset 命令
 #
 #
+if [[ $(iptables -L | grep "anti ssrf") ]]; then
+  exit
+fi
+
 ipset create ngx-ban-dstip hash:net
 ipset create ngx-ban-dstip hash:net
 
 
-# 该策略对 jsproxy 用户的所有程序都生效
 iptables \
 iptables \
+  -m comment --comment "anti ssrf" \
   -A OUTPUT \
   -A OUTPUT \
   -p tcp --syn \
   -p tcp --syn \
   -m owner --uid-owner jsproxy \
   -m owner --uid-owner jsproxy \