@@ -258,29 +258,55 @@ open_port() {
258258 echo_date " ℹ️加载xt_comment.ko内核模块!"
259259 insmod /lib/modules/${OS} /kernel/net/netfilter/xt_comment.ko
260260 fi
261- # 3.open port
261+ # 3.open v4 port
262262 local HBBSMATCH=$( iptables -t filter -S INPUT | grep " rustdesk_rule" )
263263 if [ -z " ${HBBSMATCH} " ]; then
264- echo_date " 🧱添加防火墙入站规则 ..."
265- echo_date " 🧱打开 RustDesk 服务端口 :${hbbs_used_port1} ${hbbs_used_port} ${hbbr_used_port} ${hbbs_used_port2} ${hbbr_used_port1} "
264+ echo_date " 🧱添加IPV4防火墙入站规则 ..."
265+ echo_date " 🧱打开 RustDesk IPV4服务端口 :${hbbs_used_port1} ${hbbs_used_port} ${hbbr_used_port} ${hbbs_used_port2} ${hbbr_used_port1} "
266266 iptables -I INPUT -p tcp --dport ${hbbs_used_port1} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
267267 iptables -I INPUT -p tcp --dport ${hbbs_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
268268 iptables -I INPUT -p udp --dport ${hbbs_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
269269 iptables -I INPUT -p tcp --dport ${hbbs_used_port2} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
270270 iptables -I INPUT -p tcp --dport ${hbbr_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
271271 iptables -I INPUT -p tcp --dport ${hbbr_used_port1} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
272272 fi
273+ # 检测ip6tables是否存在
274+ local IP6T=$( which ip6tables)
275+ if [ -n " ${IP6T} " ]; then
276+ # 4.open v6 port
277+ local HBBSMATCH6=$( ip6tables -t filter -S INPUT | grep " rustdesk_rule" )
278+ if [ -z " ${HBBSMATCH6} " ]; then
279+ echo_date " 🧱添加IPV6防火墙入站规则..."
280+ echo_date " 🧱打开 RustDesk IPV6服务端口:${hbbs_used_port1} ${hbbs_used_port} ${hbbr_used_port} ${hbbs_used_port2} ${hbbr_used_port1} "
281+ ip6tables -I INPUT -p tcp --dport ${hbbs_used_port1} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
282+ ip6tables -I INPUT -p tcp --dport ${hbbs_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
283+ ip6tables -I INPUT -p udp --dport ${hbbs_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
284+ ip6tables -I INPUT -p tcp --dport ${hbbs_used_port2} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
285+ ip6tables -I INPUT -p tcp --dport ${hbbr_used_port} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
286+ ip6tables -I INPUT -p tcp --dport ${hbbr_used_port1} -j ACCEPT -m comment --comment " rustdesk_rule" > /dev/null 2>&1
287+ fi
288+ fi
273289}
274290
275291close_port () {
292+ # 1.close v4 port
276293 local IPTS=$( iptables -t filter -S | grep " rustdesk_rule" | sed ' s/-A/iptables -t filter -D/g' )
277294 if [ -n " ${IPTS} " ]; then
278- echo_date " 🧱关闭本插件在防火墙上打开的所有端口 !"
295+ echo_date " 🧱关闭本插件在IPV4防火墙上打开的所有端口 !"
279296 iptables -t filter -S | grep " rustdesk_rule" | sed ' s/-A/iptables -t filter -D/g' > /tmp/rustdesk_clean.sh
280297 chmod +x /tmp/rustdesk_clean.sh
281298 sh /tmp/rustdesk_clean.sh > /dev/null 2>&1
282299 rm /tmp/rustdesk_clean.sh
283300 fi
301+ # 2.close v6 port
302+ local IP6TS=$( ip6tables -t filter -S | grep " rustdesk_rule" | sed ' s/-A/ip6tables -t filter -D/g' )
303+ if [ -n " ${IP6TS} " ]; then
304+ echo_date " 🧱关闭本插件在IPV6防火墙上打开的所有端口!"
305+ ip6tables -t filter -S | grep " rustdesk_rule" | sed ' s/-A/ip6tables -t filter -D/g' > /tmp/rustdesk_clean.sh
306+ chmod +x /tmp/rustdesk_clean.sh
307+ sh /tmp/rustdesk_clean.sh > /dev/null 2>&1
308+ rm /tmp/rustdesk_clean.sh
309+ fi
284310}
285311
286312check_status () {
0 commit comments