操作系统环境:CentOS Linux release 7.0.1406(Core) 64位
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出

备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
systemctlrestart iptables.service #最后重启防火墙使配置生效
systemctlenable iptables.service #设置防火墙开机启动

在没有找到   /etc/systemconfig/iptables 时解决办法:

执行一下命令:

  1. systemctl stop firewalld
  2. systemctl mask firewalld

并且安装iptables-services:

  1. yum install iptables-services

设置开机启动:

  1. systemctl enable iptables
  1. systemctl stop iptables
  2. systemctl start iptables
  3. systemctl restart iptables
  4. systemctl reload iptables

保存设置:

    1. service iptables save

最新文章

  1. VS2013预览版安装 体验截图
  2. SpringBoot配置属性之DataSource
  3. select制作分层级目录,让select显示和可下拉选择的"不一样"
  4. C#利用iComparable接口实现List排序
  5. ads
  6. java值得注意的几个问题
  7. java中对浮点数精度的处理DecimalFormat
  8. Android的Eclipse升级笔记
  9. Android Studio下添加引用jar文件和so文件
  10. a标签加绝对定位在图片上面,a的链接和块状属性block失效,而且是所有IE版本都失效的
  11. linux install nginx error
  12. OpenCV教程二 - Mat对象与它各种用法
  13. 网页的居中显示,使用了margin、clear:both
  14. 【IOS 开发】Objective - C 面向对象高级特性 - 包装类 | 类处理 | 类别 | 扩展 | 协议 | 委托 | 异常处理 | 反射
  15. Stream闪亮登场
  16. FastDFS数据存储
  17. ImportError: DLL load failed: 找不到指定的模块。
  18. 深度卷积网络(DCNN)和人类识别物体方法的不同
  19. 搭建Airflow数据流调度器
  20. h5直播

热门文章

  1. Python itchat.get_chatrooms() 抓取群聊不全的问题
  2. Java多线程之内存模型
  3. JavaWeb网上图书商城完整项目--27.注册页面之注册按钮图片切换实现
  4. 10、一个action中处理多个方法的调用第二种方法method的方式
  5. npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs'
  6. 上位机面试必备——TCP通信灵魂二十问【下】
  7. 入门大数据---Scala学习
  8. ajax前后端交互原理(6)
  9. ASP.NET MVC 中解决Session,Cookie等依赖的方式
  10. ASP.NET MVC 四种Controller向View传值方法