The firewall cmd command is described in detail in CentOS 7

  • 2020-05-14 05:49:00
  • OfStack

The firewall-cmd command in CentOS 7

In CentOS 7

Open the ftp service for the time being
# firewall-cmd --add-service=ftp

Open ftp service permanently
# firewall-cmd --add-service=ftp --permanent

Permanent ban
# firewall-cmd --remove-service=ftp --permanent
success

Let Settings take effect
# systemctl restart firewalld

Check if the Settings are in effect
# iptables -L -n | grep 21
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 ctstate NEW

Check 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:

The name of the service in FirewallD


# firewall-cmd --get-service
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

Query the enabled status of the service
# 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 you want to open 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:

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: