本文给各位分享centos安装iptables的知识,其中也会对CentOS安装教程进行解释,都是最近更新的内容,希望对你有所帮助!
本文目录:
- 1、CentOS 7 下使用iptables
- 2、由于centos7默认没有iptables,请简述一下,怎么安装iptables防火墙,修改配置文件
- 3、CentOS-7.5 使用 iptables
- 4、centos7怎么安装iptables
- 5、centos 7怎么手动安装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这两个依赖包
由于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 让“永久生效”的配置规则立即生效,覆盖当前的。
以上摘抄自,可以访问查看详情:
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怎么安装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 service
你可以用rpm -qa | grep iptables来查看,centos7默认防火墙是firewalld,iptables应该是没有安装,你可以用yum install iptables -y来安装。
本文关于centos安装iptables和CentOS安装教程的内容来源于网络,版权归原作者所有,如有侵权,请联系删除!
【美国高防三网直连、香港便宜VPS云服务器购买请访问:www.98cloud.com】