Linux7 白名单,Centos7 Iptables 白名单

本文档详细介绍了如何在CentOS 7上安装iptables并设置白名单,包括停止firewalld服务,安装iptables,启动iptables,以及编写脚本设定白名单规则,并通过测试验证了规则的有效性。
摘要由CSDN通过智能技术生成

Iptables是Linux操作系统常用的防火墙软件,用于服务器的访问控制。Centos7默认的防火墙是Firewalle。个人理解两者都是对规则的配置,Firewalle只是在Iptables基础上进行封装,让操作更简单。内核netfilter执行规则。

本教程使用于 RHEL 7 / CentOS 7,首选查看操作系统的版本:

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@localhost ~]#

本次测试用到的虚拟机地址:192.168.56.5;192.168.56.5;192.168.56.6

1 安装iptables

首先检查是否安装iptables,如果已经安装,或者版本比Centos7低,请略过安装Iptables的步骤,直接看使用和配置。

(1)检查是否安装iptables

[root@localhost ~]# service iptables status

Redirecting to /bin/systemctl status iptables.service

Unit iptables.service could not be found.

[root@localhost ~]#

(2)安装前的准备

#停止firewalle

[root@localhost ~]# systemctl stop firewalld

#禁用firewalld服务

[root@localhost ~]# systemctl mask firewalld

Created symlink from /etc/systemd/system/firewalld.service to /dev/null.

[root@localhost ~]#

1.1 yum安装

如果目标服务器能够联网,可选择yum的方式安装。

#yum安装iptables

[root@localhost ~]# yum install iptables-services

已加载插件:fastestmirror

Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

base | 3.6 kB 00:00

extras | 3.4 kB 00:00

updates | 3.4 kB 00:00

(1/4): base/7/x86_64/group_gz | 166 kB 00:00:00

(2/4): extras/7/x86_64/primary_db | 200 kB 00:00:00

(3/4): base/7/x86_64/primary_db | 6.0 MB 00:00:02

(4/4): 3/3

……省略中间安装日志……

已安装:

iptables-services.x86_64 0:1.4.21-28.el7

作为依赖被升级:

iptables.x86_64 0:1.4.21-28.el7

完毕!

[root@localhost ~]#

(2)安装后验证

#查看是否安装成功

[root@springb

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值