手机版
你好,游客 登录 注册
背景:
阅读新闻

Centos7.2 启用iptables

[日期:2017-09-09] 来源:Linux社区  作者:Linux [字体: ]

一、防火墙iptables 简洁介绍

iptables 和 firewalld 都是工作在用户空间、用来定义规则的工具,本身不是防火墙,他们定义的规则,可以让内核空间当中的netfilter读取,并且实现防火墙工作。

netfilter是操作系统核心层内部的一个数据包处理模块,它具有如下功能:

  1.网络地址转换 nat

  2.数据包内容修改 mangle

  3.数据包过滤的防火墙功能 filter  

CentOS7.2  默认使用firewalld ;iptables默认无法被systemctl控制,需要安装iptables-services、iptables-devel这两个依赖包

二、将firewalld切换到 iptables

1. 停止并禁用 firewalld

sudo systemctl stop firewald.service && sudo systemctl disable firewald.service

2.安装iptables-services、iptables-devel

sudo yum install iptables-services iptables-devel

3.启用并启动iptables

sudo systemctl enable iptables.service && sudo systemctl start iptables.service

4.查看iptables配置文件

sudo vim /etc/sysconfig/iptables

5.开启转发功能

(1) 在 /etc/sysctl.conf 中添加 net.ipv4.ip_forward=1

(2) sudo sysctl -p 同步内核参数

(3) 继续查看内核参数 less /proc/sys/net/ipv4/ip_forward  如果为1 则配置生效

更多iptables相关教程见以下内容

CentOS 7.0关闭默认防火墙启用iptables防火墙  http://www.linuxidc.com/Linux/2015-05/117473.htm

Iptables工作原理使用详解 http://www.linuxidc.com/Linux/2016-09/134945.htm

Ubuntu 14.04 配置iptables防火墙 http://www.linuxidc.com/Linux/2017-02/140556.htm

Linux下编译安装iptables  http://www.linuxidc.com/Linux/2017-04/142615.htm

iptables的备份、恢复及防火墙脚本的基本使用 http://www.linuxidc.com/Linux/2013-08/88535.htm

Iptables工作原理使用详解  http://www.linuxidc.com/Linux/2016-09/134945.htm

CentOS7下iptables配置过程 http://www.linuxidc.com/Linux/2017-01/139622.htm

Linux下iptables防火墙设置 http://www.linuxidc.com/Linux/2015-10/123843.htm

Linux防火墙iptables详解  http://www.linuxidc.com/Linux/2016-12/138474.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-09/146813.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款