启动防火墙:systemctl start firewalld.service
关闭防火墙:systemctl stop firewalld.service
重启防火墙:systemctl restart firewalld.service
显示防火墙服务状态:systemctl status firewalld.service
在开机时启用防火墙服务:systemctl enable firewalld.service
在开机时禁止防火墙服务:systemctl disable firewalld.service
查看防火墙服务是否开机启动:systemctl is-enabled firewalld.service;echo $?
查看已启动的服务列表:systemctl list-unit-files | grep enabled
查看防火墙状态:systemctl status firewalld.service
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