[root@hf-01 ~]# firewall-cmd --get-services //列出系统中所有的services
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 openV** 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
[root@hf-01 ~]#
[root@hf-01 ~]# firewall-cmd --get-default-zone //查看当前的zone
work
[root@hf-01 ~]# firewall-cmd --list-services //查看当前zone下有哪些service
dhcpv6-client ipp-client ssh
[root@hf-01 ~]#
[root@hf-01 ~]# firewall-cmd --zone=public --list-services
dhcpv6-client ssh
[root@hf-01 ~]#
[root@hanfeng ~]# firewall-cmd --zone=public --add-service=http
success
[root@hanfeng ~]# firewall-cmd --zone=public --list-service
dhcpv6-client http ssh
[root@hanfeng ~]# firewall-cmd --zone=public --add-service=ftp
success
[root@hanfeng ~]# firewall-cmd --zone=public --list-service
dhcpv6-client ftp http ssh
[root@hanfeng ~]#
[root@hanfeng ~]# firewall-cmd --zone=public --add-service=http --permanent
success
[root@hanfeng ~]# ls /etc/firewalld/zones/ //每次改完配置文件,就会生成一个旧的作为备份,后缀名为.old
public.xml public.xml.old
[root@hanfeng ~]# cat /etc/firewalld/zones/public.xml //查看更改后的配置文件
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="dhcpv6-client"/>
<service name="http"/>
<service name="ssh"/>
</zone>
[root@hanfeng ~]#
[root@hanfeng ~]# ls /usr/lib/firewalld/zones/
block.xml drop.xml home.xml public.xml work.xml
dmz.xml external.xml internal.xml trusted.xml
[root@hanfeng ~]# ls /usr/lib/firewalld/services/
amanda-client.xml ipp-client.xml mysql.xml rpc-bind.xml
bacula-client.xml ipp.xml nfs.xml samba-client.xml
bacula.xml ipsec.xml ntp.xml samba.xml
dhcpv6-client.xml kerberos.xml openV**.xml smtp.xml
dhcpv6.xml kpasswd.xml pmcd.xml ssh.xml
dhcp.xml ldaps.xml pmproxy.xml telnet.xml
dns.xml ldap.xml pmwebapis.xml tftp-client.xml
ftp.xml libvirt-tls.xml pmwebapi.xml tftp.xml
high-availability.xml libvirt.xml pop3s.xml transmission-client.xml
https.xml mdns.xml postgresql.xml vnc-server.xml
http.xml mountd.xml proxy-dhcp.xml wbem-https.xml
imaps.xml ms-wbt.xml radius.xml
[root@hanfeng ~]#
[root@hanfeng ~]# cp /usr/lib/firewalld/services/ftp.xml /etc/firewalld/services
[root@hanfeng ~]# vi /etc/firewalld/services/ftp.xml
将内容中的21端口改为1121端口
[root@hanfeng ~]# cp /usr/lib/firewalld/zones/work.xml /etc/firewalld/zones/
[root@hanfeng ~]# vi /etc/firewalld/zones/work.xml
增加一行,内容为 <service name="ftp"/>
[root@hanfeng ~]# firewall-cmd --reload //重新加载
success
[root@hanfeng ~]# firewall-cmd --zone=work --list-services
dhcpv6-client ftp ipp-client ssh
[root@hanfeng ~]#