您当前的位置:易学堂 > 日志记录

RHEL7开启iptables

时间:2019-04-12 09:20:53

前言

iptables 组件是一种工具,也称为用户空间(userspace),它使插入、修改和除去信息包过滤表中的规则变得容易。在Red Hat Linux 7.1 或更高版本中,防火墙服务默认使用的是 firewalld ,iptables已不是默认防火墙配置软件,需要下载该工具并安装使用它。

正文

以虚拟机本地镜像安装为例,1、首先挂载本地镜像:

mkdir /iso
mount /dev/cdrom /iso

需要注意的是,虚拟机设置安装镜像正确挂载并连接,图形化桌面会出现光盘图标。

2、配置yum源文件:

vim /etc/yum.repos.d/ dvd.repo

[dvd]
name=dvd   #自定义名称 
baseurl= ftp://192.168.1.6/pub/Packages #ftp访问路径 
enabled=1   #启用yum源,0为不启用,1为启用 
gpgcheck=0  #检查GPG-KEY,0为不检查,1为检查 

:wq! #保存退出 

3、安装iptables和iptables-services

yum clean all   #清除yum缓存 
yum makecache  #缓存本地yum源中的软件包信息
yum install iptables-services iptabless -y #直接安装

4、默认状态firewalld是默认启动的,需要关闭它再启动iptables

systemctl status firewalld.service #检测是否开启了firewall

systemctl stop firewalld.service #关闭firewall

sytsemctl disable firewalld.service #禁止firewall开机自启

附命令:

firewall-cmd --reload #重启firewall

firewall-cmd --complete-reload #完全重启


systemctl enable iptables #启用iptables

systemctl start iptables #开启iptables

systemctl status iptables #查看状态

11.jpg

测试一下:

22.jpg

好了,iptables已经开启了,剩下的开始设置规则吧,但是请特别注意,使用iptables命令配置的防火墙规则默认会在系统下一次重启时失效,如果想让配置的防火墙策略永久生效,还要执行保存命令:service iptables save

标签: RHEL7

上一篇:学无止境

下一篇:Ghost 实用说明