2.软文推荐
3.软文推荐
firewalld是centos7系统默认的防火墙,和iptables一样,是使用系统中netfilter内核模块的管理工具。和iptables不一样的点 firewalld 使用区域和服务而不是链式规则。 它动态管理规则集,允许更新规则而不破坏现有会话和连接。
FirewallD 使用服务service 和区域zone来代替 iptables 的规则rule和链chain。
默认情况下,有以下的区域zone可用:
要列出所有可用的区域,运行:
# firewall-cmd --get-zones
work drop internal external trusted home dmz public block
列出默认的区域 :
# firewall-cmd --get-default-zone
public
改变默认的区域 :
# firewall-cmd --set-default-zone=dmz
# firewall-cmd --get-default-zone
dmz
FirewallD 服务
FirewallD 服务使用 XML 配置文件,记录了 firewalld 服务信息。
列出所有可用的服务:
# firewall-cmd --get-services
amanda-client amanda-k5-client bacula bacula-client ceph ceph-mon dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp smtps snmp snmptrap squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server
XML 配置文件存储在 /usr/lib/firewalld/services/ 和 /etc/firewalld/services/ 目录下。
作为一个例子,假设你正在运行一个 web 服务器,SSH 服务端口为 7022 ,以及邮件服务,你可以利用 FirewallD 这样配置你的服务器:
首先设置默认区为 dmz。
# firewall-cmd --set-default-zone=dmz
# firewall-cmd --get-default-zone
dmz
为 dmz 区添加持久性的 HTTP 和 HTTPS 规则:
# firewall-cmd --zone=dmz --add-service=http --permanent
# firewall-cmd --zone=dmz --add-service=https --permanent
开启端口 25 (SMTP) 和端口 465 (SMTPS) :
firewall-cmd --zone=dmz --add-service=smtp --permanent
firewall-cmd --zone=dmz --add-service=smtps --permanent
开启 IMAP、IMAPS、POP3 和 POP3S 端口:
firewall-cmd --zone=dmz --add-service=imap --permanent
firewall-cmd --zone=dmz --add-service=imaps --permanent
firewall-cmd --zone=dmz --add-service=pop3 --permanent
firewall-cmd --zone=dmz --add-service=pop3s --permanent
因为将 SSH 端口改到了 7022,所以要移除 ssh 服务(端口 22),开启端口 7022:
firewall-cmd --remove-service=ssh --permanent
firewall-cmd --add-port=7022/tcp --permanent
要应用这些更改,我们需要重新加载防火墙:
firewall-cmd --reload
最后可以列出这些规则:
# firewall-cmd –list-all
dmz
target: default
icmp-block-inversion: no
interfaces:
sources:
services: http https imap imaps pop3 pop3s smtp smtps
ports: 7022/tcp
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
本文来源:www.lxlinux.net/6788.html,若引用不当,请联系修改。

立即
返回
1
softshellweb近期发布了商家的春季优惠,商家一家公司运营的IDC,本次商家针对中国台湾和荷兰阿姆斯特丹机房进行了促销,不过力度一般,...