云服务器免费试用

centos安装iptables(CentOS安装docker)

服务器知识 0 1382

本文目录:

  • 1、centos7怎么安装iptables
  • 2、CentOS 7 下使用iptables
  • 3、centosstream9防火墙配置保存
  • 4、CentOS-7.5 使用 iptables
  • 5、centos 安装iptables和iptables-services

centos7怎么安装iptables

关闭firewall:

[root@linuxprobe ~]# systemctl stop firewalld.service #停止firewall

[root@linuxprobe ~]# systemctl disable firewalld.service #禁止firewall开机启动

关闭iptables:

[root@linuxprobe ~]# systemctl stop iptables.service #停止iptables服务

其他参数:

[root@linuxprobe ~]# systemctl start iptables #开启iptables防火墙

[root@linuxprobe ~]# systemctl restart iptables.service #重启防火墙使配置

[root@linuxprobe ~]# systemctl enable iptables.service #设置防火墙开机启动

CentOS 7 下使用iptables

iptables/netfilter(下文中简称为iptables)组成Linux平台下的包过滤防火墙,含有网络地址转换(Network Address Translate)、数据包内容修改以及数据包过滤等功能。

iptables内置了4个表优先级次序(由高而低):raw -- mangle -- nat -- filter

iptables上有5条链

CentOS 7 默认使用firewalld.service,要想切换iptables.service需要安装iptables(默认已经安装了)和iptables-services这两个依赖包

centosstream9防火墙配置保存

操作系统

为CentOS系统配置防火墙设置

weixin_30649859

转载

关注

0点赞·37人阅读

 

在各种操作系统中,为了保护系统在网络中是相对安全的,我们通常都会给操作系统配置防火墙,通过配置防火墙来限定哪些流量可以进来,哪些流量可以出去,通过这样的一种方式,可以有效的管理系统的流量,从一定程度上保证系统的安全。

下面襄阳网站优化就来讲讲 CentOS 这款常用的服务器操作系统的防火墙配置情况:

在CentOS 系列的系统中,CentOS_7.x以上默认firewall为防火墙配置,为了解决防火墙安全这个问题,我们使用iptables配置 来代替原有的 firewall 配置。

一、首先查看默认防火墙状态

1firewall-cmd --state

(关闭后显示not running,开启后显示running)

如果 firewall 正在运行,那么我们先将它关闭,命令如下:

1

2systemctl stop firewalld.service

systemctl disable firewalld.service

下面在给大家提供一些关于默认firewlall防火墙的操作指令:

添加: firewall-cmd –zone=public –add-port=80/tcp –permanent (–permanent永久生效,没有此参数重启后失效)

重载: firewall-cmd –reload

查看: firewall-cmd –zone=public –query-port=80/tcp

删除: firewall-cmd –zone= public –remove-port=80/tcp –permanent

二、配置 iptables 规则

在配置iptables前,我们需要安装iptables服务:

1yum install iptables-services

安装好后,开始编辑这个防火墙配置文件,该文件存放在 /etc/sysconfig/iptables 目录中:

1vim /etc/sysconfig/iptables

加入以下代码:

-A INPUT -p tcp -m state –state NEW

CentOS-7.5 使用 iptables

1、关闭 firewalld

由于 firewalld 是 CentOS-7系列的默认防火墙,因此如果想使用iptables的话,需要将CentOS-7系列的默认防火墙 firewalld 关闭,并安装 iptables-services 

[root@shell ~]#

[root@shell ~]# systemctl  stop  firewalld.service            #关闭

[root@shell ~]# systemctl  disable  firewalld.service        #禁止开机自启动

[root@shell ~]# firewall-cmd  --state          #查看firewalld是否在运行

not  running

[root@shell ~]#

2、安装iptables防火墙

[root@shell ~]#

[root@shell ~]# yum install iptables-services                  #安装iptables服务

[root@shell ~]# systemctl  start  iptables

[root@shell ~]# systemctl  enable  iptables                      #设置iptables为开机自启动

[root@shell ~]#

[root@shell ~]# cat  /etc/sysconfig/iptables            #查看iptables默认配置

[root@shell ~]# 

[root@shell ~]#

[root@shell ~]# systemctl  start  iptables             #启动 iptables

[root@shell ~]# systemctl  status  iptables            #查看状态

[root@shell ~]#

[root@shell ~]# iptables  -L                  #查看当前防火墙规则

3、配置防火墙规则

centos 安装iptables和iptables-services

查看当前系统是否安装防火墙

安装 iptables

安装 iptables-services

查看iptables现有规则

防火墙是需要开启80端口,不然外网就不能访问到主机资源。

开启相关规则的命令:

保存配置,并重启:

【centos安装iptables】的内容来源于互联网,如引用不当,请联系我们修改。

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942@qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: centos安装iptables(CentOS安装docker)
本文地址: https://solustack.com/24688.html

相关推荐:

网友留言:

我要评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。