封锁Linux端口防止Spam被商家suspended

从Lop博客转了一段代码过来,这样可以有效防止别人在VPS上面捣乱了。
#!/bin/bash
#input rules
iptables -A OUTPUT -p tcp -m multiport –dports 25,26,109,110,143,220,366,465,587,691,993,995,2710,6881 -j REJECT –reject-with tcp-reset
iptables -A OUTPUT -p udp -m multiport –dports 25,26,109,110,143,220,366,465,587,691,993,995,2710,6881 -j DROP
#save
iptables-save > /etc/iptables
touch /etc/network/if-pre-up.d/iptables
chmod +x /etc/network/if-pre-up.d/iptables
echo “#!/bin/sh” >> /etc/network/if-pre-up.d/iptables
echo “/sbin/iptables-restore < /etc/iptables" >> /etc/network/if-pre-up.d/iptables
iptables-save > /etc/iptables
iptables -L

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注