lnmp 预设iptables设置

「LNMP」iptables初始配置

 

首先使用命令iptables -P INPUT ACCEPT允许所有连接,否则容易把自己关在外边。
然后使用iptables -F;iptables -X;iptables -Z清除所有规则;
再添加iptables -A INPUT -p tcp --dport 22 -j ACCEPT允许SSH;
随后调整预设规则:

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

允许合法连接:

iptables -I INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -I INPUT -m state --state INVALID -j DROP

之后自由发挥,该允许啥允许啥,比如我主要用来挂网站,就需要开放80与443端口,其余按需设置即可

原文地址:https://www.cnblogs.com/dragonflyer/p/6143570.html