The firewall-cmd command in CentOS 7, centosfirewall-cmd
In CentOS 7
Ftp service is currently available
# Firewall-cmd -- add-service = ftp
Permanently open ftp service
# Firewall-cmd -- add-service = ftp -- permanent
Permanently close
# Firewall-cmd -- remove-service = ftp -- permanent
Success
Make settings take effect
# Systemctl restart firewalld
Check whether the settings take effect
# Iptables-L-n | grep 21
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 21 ctstate NEW
Check the Firewall Status
# Firewall-cmd -- state
Running
# Systemctl stop firewalld
# Firewall-cmd -- state
Not running
# Firewall-cmd -- list-all
Public (default)
Interfaces:
Sources:
Services: dhcpv6-client ftp ssh
Ports:
Masquerade: no
Forward-ports:
Icmp-blocks:
Rich rules:
Service name in FirewallD
# Firewall-cmd -- get-service
Amanda-client bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp-client ipsec kerberos kpasswd ldap ldaps libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba-client smtp ssh telnet tftp-client transmission-client vnc-server wbem-https
Query the Service Activation status
# Firewall-cmd -- query-service ftp
Yes
# Firewall-cmd -- query-service ssh
Yes
# Firewall-cmd -- query-service samba
No
# Firewall-cmd -- query-service http
No
Add the Port to be opened by yourself
# Firewall-cmd -- add-port = 3128/tcp
# Firewall-cmd -- list-all
Public (default)
Interfaces:
Sources:
Services: dhcpv6-client ftp ssh
Ports: 3128/tcp
Masquerade: no
Forward-ports:
Icmp-blocks:
Rich rules: