啓動防火牆:systemctl start firewalld.servicepython
關閉防火牆:systemctl stop firewalld.servicedocker
重啓防火牆:systemctl restart firewalld.servicedom
顯示防火牆服務狀態:systemctl status firewalld.servicetcp
在開機時啓用防火牆服務:systemctl enable firewalld.servicespa
在開機時禁止防火牆服務:systemctl disable firewalld.servicerest
查看防火牆服務是否開機啓動:systemctl is-enabled firewalld.service;echo $?code
查看已啓動的服務列表:systemctl list-unit-files | grep enabledblog
查看防火牆狀態:systemctl status firewalld.serviceip
systemctl list-unit-files | grep firewalld.service作用域
firewall-cmd --state
[root@localhost bin]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since 二 2018-03-06 23:00:54 CST; 2min 10s ago Docs: man:firewalld(1) Main PID: 37299 (firewalld) Memory: 25.1M CGroup: /system.slice/firewalld.service └─37299 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 3月 06 23:00:55 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT...ailed: 3月 06 23:00:55 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -i docker0 ...ailed: 3月 06 23:00:55 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --delete INPUT...ailed: 3月 06 23:00:55 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -i docker0 ...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C PREROUTING -m addrtype...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C OUTPUT -m addrtype --d...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 ...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 ...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -j DOCKER-I...ailed: 3月 06 23:00:56 localhost.localdomain firewalld[37299]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -D FORWARD -i docker0 -o docker0...ailed: Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost bin]# systemctl list-unit-files | grep firewalld.service firewalld.service enabled
[root@localhost bin]# firewall-cmd --state
running
查看已經開放的端口
firewall-cmd --list-ports
[root@localhost bin]# firewall-cmd --list-ports 8080/tcp
開啓端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
命令含義:
--zone #做用域
--add-port=8080/tcp #天假端口,格式爲:端口/通信協議
--permanent #永久生效,沒有此參數重啓後失效
重啓防火牆
firewall-cmd --reload