1.基本使用
- 啟動
[root@centos]# systemctl start firewalld
- 停止
[root@centos]# systemctl stop firewalld
- 啟用
[root@centos]# systemctl enable firewalld
- 禁用
[root@centos]# systemctl disable firewalld
- 查看狀態
[root@centos]# systemctl status firewalld
2. systemctl是CentOS7的服務管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。
- 啟動一個服務:
[root@centos]# systemctl start firewalld.service
- 關閉一個服務:
[root@centos]# systemctl stop firewalld.service
- 重啟一個服務:
[root@centos]# systemctl restart firewalld.service
- 顯示一個服務的狀態:
[root@centos]# systemctl status firewalld.service
- 在開機時啟用一個服務:
[root@centos]# systemctl enable firewalld.service
- 在開機時禁用一個服務:
[root@centos]# systemctl disable firewalld.service
- 查看服務是否開機啟動:
[root@centos]# systemctl is-enabled firewalld.service
- 查看已啟動的服務列表:
[root@centos]# systemctl list-unit-files|grep enabled
- 查看啟動失敗的服務列表:
[root@centos]# systemctl --failed
3. 配置firewalld-cmd
- 查看版本:
[root@centos]# firewall-cmd --version
- 查看幫助:
[root@centos]# firewall-cmd --help
- 顯示狀態:
[root@centos]# firewall-cmd --state
- 查看所有打開的端口:
[root@centos]# firewall-cmd --zone=public --list-ports
- 更新防火墻規則:
[root@centos]# firewall-cmd --reload
- 查看區域信息:
[root@centos]# firewall-cmd --get-active-zones
- 查看指定接口所屬區域:
[root@centos]# firewall-cmd --get-zone-of-interface=eth0
- 拒絕所有包:
[root@centos]# firewall-cmd --panic-on
- 取消拒絕狀態:
[root@centos]# firewall-cmd --panic-off
- 查看是否拒絕:
[root@centos]# firewall-cmd --query-panic
那怎么開啟一個端口呢
- 添加
# --permanent永久生效,沒有此參數重啟后失效
[root@centos]# firewall-cmd --zone=public --add-port=80/tcp --permanent
- 重新載入
[root@centos]# firewall-cmd --reload
- 查看
[root@centos]# firewall-cmd --zone= public --query-port=80/tcp
- 刪除
[root@centos]# firewall-cmd --zone= public --remove-port=80/tcp --permanent