Linux配置防火墙 开启80端口、3306端口的方法
程序员文章站
2022-05-27 13:02:42
Linux下在防火墙中开启80端口、3306端口的方法,需要的朋友可以参考下... 12-10-16...
vi /etc/sysconfig/iptables
-a input -m state –state new -m tcp -p tcp –dport 80 -j accept(允许80端口通过防火墙)
-a input -m state –state new -m tcp -p tcp –dport 3306 -j accept(允许3306端口通过防火墙)
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
添加好之后防火墙规则如下所示:
# firewall configuration written by system-config-firewall
# manual customization of this file is not recommended.
*filter
:input accept [0:0]
:forward accept [0:0]
:output accept [0:0]
-a input -m state –state established,related -j accept
-a input -p icmp -j accept
-a input -i lo -j accept
-a input -m state –state new -m tcp -p tcp –dport 22 -j accept
-a input -m state –state new -m tcp -p tcp –dport 80 -j accept
-a input -m state –state new -m tcp -p tcp –dport 3306 -j accept
-a input -j reject –reject-with icmp-host-prohibited
-a forward -j reject –reject-with icmp-host-prohibited
commit
/etc/init.d/iptables restart
#最后重启防火墙使配置生效
-a input -m state –state new -m tcp -p tcp –dport 80 -j accept(允许80端口通过防火墙)
-a input -m state –state new -m tcp -p tcp –dport 3306 -j accept(允许3306端口通过防火墙)
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
添加好之后防火墙规则如下所示:
复制代码
代码如下:# firewall configuration written by system-config-firewall
# manual customization of this file is not recommended.
*filter
:input accept [0:0]
:forward accept [0:0]
:output accept [0:0]
-a input -m state –state established,related -j accept
-a input -p icmp -j accept
-a input -i lo -j accept
-a input -m state –state new -m tcp -p tcp –dport 22 -j accept
-a input -m state –state new -m tcp -p tcp –dport 80 -j accept
-a input -m state –state new -m tcp -p tcp –dport 3306 -j accept
-a input -j reject –reject-with icmp-host-prohibited
-a forward -j reject –reject-with icmp-host-prohibited
commit
/etc/init.d/iptables restart
#最后重启防火墙使配置生效
上一篇: 人体5大黄金穴:再不揉起就老了
下一篇: 养生保健常按六穴位 按腋窝宽胸宁神