The Centos 7 Firewalld commands are described in detail

  • 2020-05-24 06:42:37
  • OfStack

The Centos 7 and Firewalld commands are described in detail

Introduction: Centos 7 is a very popular distribution of Linux. This article focuses on how to start a service and add a service or port using the firewalld command.

1. Check the firewall service status

> > systemctl status firewalld


[root@flybird ~]# systemctl status firewalld 
 low  firewalld.service - firewalld - dynamic firewall daemon 
  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) 
  Active: inactive (dead) 

Show that the current firewall is not started

2. Start/close firewall

> > systemctl start/stop firewalld


root@flybird ~]# systemctl start firewalld 
[root@flybird ~]# systemctl status firewalld 
 low  firewalld.service - firewalld - dynamic firewall daemon 
  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) 
  Active: active (running) since Fri 2016-12-02 23:17:09 CST; 11s ago 
 Main PID: 1279 (firewalld) 
  CGroup: /system.slice/firewalld.service 
       └ ─ 1279 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 

3. Disable or enable firewall

> > systemctl disable/enable firewalld

4. Check if the port is open

> > > firewall-cmd --query-port=8020/tcp

5. New development port

> > firewall-cmd --add-port=5000/tcp --permanent


[root@flybird ~]# firewall-cmd --query-port=5000/tcp 
no 
[root@flybird ~]# firewall-cmd --add-port=5000/tcp --permanent 
success 

6. About services

> > firewall-cmd --add-service=ftp --permanent

> > firewall-cmd --remove-service=ftp --permanent

7. View firewall status

> > firewall-cmd --status

> > systemctl status firewalld

8. View what firewall is currently open to

> > firewall-cmd --list-all


[root@flybird ~]# firewall-cmd --list-all 
public (default) 
 interfaces:  
 sources:  
 services: dhcpv6-client http ssh 
 ports: 443/tcp 80/tcp 3306/tcp 6739/tcp 10051/tcp 10050/tcp 
 masquerade: no 
 forward-ports:  
 icmp-blocks:  
 rich rules:  

9. View the port being developed

> > firewall-cmd --list-port

10. See the instructions for the firewall-cmd command

> > firewall-cmd --help

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


Related articles: