CentOS 6.5系统下iptables防火墙开放80 3306 22端口

最近在搭建LAMP环境,配置各种环境时需要开放端口,总是在百度太麻烦了,记录一下

原文地址:http://m.blog.csdn.net/sherwin/article/details/49562667

-------------------------------------------------------------------------

#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

#/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
然后保存:
#/etc/rc.d/init.d/iptables save

查看打开的端口:

# /etc/init.d/iptables status

-------------------------------------------------------

补充说明:

#关闭防火墙

/etc/init.d/iptables stop

service iptables stop # 停止服务 #查看防火墙信息

/etc/init.d/iptables status

#开放端口:8080

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

#重启防火墙以便改动生效:(或者直接重启系统)

/etc/init.d/iptables restart

#将更改进行保存

/etc/rc.d/init.d/iptables save

另外直接在/etc/sysconfig/iptables中增加一行:

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT #永久关闭防火墙 chkconfig –level 35 iptables off #此方法源自网络,未实验,安全考虑拒绝使用此方法

相关文章

#使用军哥的lnmp配置虚拟主机,需要注意的是要配置hosts文件(...
一、配置编译环境 yum update && yum upgra...
一、下载repo文件 二、备份并替换系统的repo文件 三、执行yu...
LAMP -- Linux Apache MySQL PHP 在CentOS安装的顺序,我一般...
一、下载nginx安装包,官网下载中心http://nginx.org/downlo...
1.下载composer curl -sS https://getcomposer.org/installe...