欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

Linux配置防火墙 开启80端口、3306端口的方法

程序员文章站 2024-01-23 16:31:28
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
#最后重启防火墙使配置生效