红帽RHEL7系统已经用firewalld服务替代了iptables服务(但依然可以使用iptables命令来管理内核的netfilter),新的防火墙管理命令firewall-cmd与图形化工具firewall-config。
本质上,firewalld跟iptables是同样的东西,都只是用来定义防火墙规则功能的“防火墙管理工具”,将定义好的规则交由内核中的netfilter即网络过滤器来读取,从而真正实现防火墙功能,底层其实还是netfilter.
只是,firewalld比iptables更简单更智能化。
在rhel7 和centos7 ,可以直接把iptables 给禁用了,直接用firewalld.
iptables命令用于创建数据过滤与NAT规则,主流的Linux系统都会默认启用iptables命令,但其参数较多且规则策略相对比较复杂。
Firewalld服务是红帽RHEL7系统中默认的防火墙管理工具,特点是拥有运行时配置与永久配置选项且能够支持动态更新以及"zone"的区域功能概念,使用图形化工具firewall-config或文本管理工具firewall-cmd,
---- firewalld 简单命令
大部分安装RHEL7系统时会自动安装firewalld。如果需要手动安装可以执行以下安装指令:
# yum install firewalld firewall-config
说明:firewalld为服务包,firewall-config为图形化界面配置工具
#启动firewall
systemctl start firewalld.service
#设置firewall开机启动
systemctl enable firewalld.service
--取消开机启动
systemctl disable firewalld
#查看firewall状态
systemctl status firewalld
#查看firewall是否开启,“active”表示已启动
systemctl is-active firewalld
#停止firewall
systemctl stop firewalld.service
-- 开放指定端口
firewall-cmd --add-port=50002/tcp --zone=public --permanent
-- 关闭指定端口
firewall-cmd --remove-port=50002/tcp --zone=public --permanent
-- reload,使配置变更生效
firewall-cmd --reload
-- 查看指定端口是否已放开
iptables -L -n | grep 50002
-- 结果为“ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:50002 ctstate NEW”表示已放开
-- 无输出,表示未放开
-- 在fallwall的服务
firewall-cmd --get-service
-- 输出结果:
RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https
-- 开放指定服务
firewall-cmd --add-service=http --zone=public --permanent
-- 关闭指定服务
firewall-cmd --remove-service=http --zone=public --permanent
-- 查询服务的启用状态 no表示未启用,yes表示已启用
firewall-cmd --query-service http
iptables:
http://huangqiqing123.iteye.com/blog/2241342
RHEL,即Red Hat Enterprise Linux