2022
我们一起努力

centos7安装iptables(centos7安装oracle11g)

本文目录:

  • 1、centos7怎么安装iptables
  • 2、CentOS-7.5 使用 iptables
  • 3、centos7最小安装怎么安装防火墙
  • 4、CentOS 7 下使用iptables
  • 5、centos7 iptables启动失败,提示Failed to start IPv4 firewall
  • 6、由于centos7默认没有iptables,请简述一下,怎么安装iptables防火墙,修改配置文件

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.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、配置防火墙规则

centos7最小安装怎么安装防火墙

CentOS 7.0默认使用的是firewall作为防火墙,需要事先关闭。

关闭firewall:

systemctl stop firewalld.service

systemctl disable firewalld.service

systemctl mask firewalld.service

安装iptables防火墙

yum install iptables-services -y

启动设置防火墙

systemctl enable iptables

systemctl start iptables

查看防火墙状态

systemctl status iptables

启动设置防火墙

vi /etc/sysconfig/iptables #编辑防火墙配置文件

-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

:wq! #保存退出

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这两个依赖包

centos7 iptables启动失败,提示Failed to start IPv4 firewall

centos7重启iptables时失败,通过systemctl status iptables.service查看错误信息,内容如下所示:

# *systemctl status iptables.service

上面的错误是在启动ipv4 firewall时失败,可尝试关闭firewalld服务在重启iptables:

除了使用上述的方法以外,启动失败的原因也可能是iptables的规则配置错误。

可以check下/etc/sysconfig/iptables文件。

由于centos7默认没有iptables,请简述一下,怎么安装iptables防火墙,修改配置文件

centos 7 和 redhat 7 一样,用firewalld代替了旧版本的 iptables。

新的防火墙管理命令firewall-cmd与图形化工具firewall-config。

Firewalld服务是红帽RHEL7系统中默认的防火墙管理工具,特点是拥有运行时配置与永久配置选项且能够支持动态更新以及”zone”的区域功能概念,使用图形化工具firewall-config或文本管理工具firewall-cmd,下面实验中会讲到~

8.3.1 区域概念与作用

防火墙的网络区域定义了网络连接的可信等级,我们可以根据不同场景来调用不同的firewalld区域,区域规则有:

编辑

区域 默认规则策略

trusted 允许所有的数据包。

home 拒绝流入的数据包,除非与输出流量数据包相关或是ssh,mdns,ipp-client,samba-client与dhcpv6-client服务则允许。

internal 等同于home区域

work 拒绝流入的数据包,除非与输出流量数据包相关或是ssh,ipp-client与dhcpv6-client服务则允许。

public 拒绝流入的数据包,除非与输出流量数据包相关或是ssh,dhcpv6-client服务则允许。

external 拒绝流入的数据包,除非与输出流量数据包相关或是ssh服务则允许。

dmz 拒绝流入的数据包,除非与输出流量数据包相关或是ssh服务则允许。

block 拒绝流入的数据包,除非与输出流量数据包相关。

drop 拒绝流入的数据包,除非与输出流量数据包相关。

简单来讲就是为用户预先准备了几套规则集合,我们可以根据场景的不同选择合适的规矩集合,而默认区域是public。

8.3.2 字符管理工具

如果想要更高效的配置妥当防火墙,那么就一定要学习字符管理工具firewall-cmd命令,命令参数有:

编辑

参数 作用

–get-default-zone 查询默认的区域名称。

–set-default-zone=区域名称 设置默认的区域,永久生效。

–get-zones 显示可用的区域。

–get-services 显示预先定义的服务。

–get-active-zones 显示当前正在使用的区域与网卡名称。

–add-source= 将来源于此IP或子网的流量导向指定的区域。

–remove-source= 不再将此IP或子网的流量导向某个指定区域。

–add-interface=网卡名称 将来自于该网卡的所有流量都导向某个指定区域。

–change-interface=网卡名称 将某个网卡与区域做关联。

–list-all 显示当前区域的网卡配置参数,资源,端口以及服务等信息。

–list-all-zones 显示所有区域的网卡配置参数,资源,端口以及服务等信息。

–add-service=服务名 设置默认区域允许该服务的流量。

–add-port=端口号/协议 允许默认区域允许该端口的流量。

–remove-service=服务名 设置默认区域不再允许该服务的流量。

–remove-port=端口号/协议 允许默认区域不再允许该端口的流量。

–reload 让“永久生效”的配置规则立即生效,覆盖当前的。

以上摘抄自,可以访问查看详情:

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

赞(0)
文章名称:《centos7安装iptables(centos7安装oracle11g)》
文章链接:https://www.fzvps.com/24092.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!