Centos 7之Firewalld相关命令详细介绍

Centos 7之Firewalld相关命令详细介绍

引言:Centos 7是目前非常流行的Linux发行版本,本文将重点介绍如何来使用firewalld相关命令启动服务以及添加服务或者端口等操作。

1.  查看firewall服务状态

  >>  systemctl status firewalld

[root@flybird ~]# systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: inactive (dead)

 显示当前的firewall并未启动

2.  启动/关闭firewall

  >> systemctl start/stop firewalld

root@flybird ~]# systemctl start firewalld

[root@flybird ~]# systemctl status firewalld

● 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.  禁用或者启用firewall

  >> systemctl disable/enable firewalld

4.  查看端口是否开放

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

5. 新增开发端口

  >> 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.  关于服务

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

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

7.  查看firewall状态

   >> firewall-cmd --status

   >>  systemctl status firewalld

8. 查看 firewall目前开放的内容

   >> 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.  查看开发的端口

  >> firewall-cmd --list-port

10. 查看firewall-cmd命令的使用说明

   >> firewall-cmd --help

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

以上是 Centos 7之Firewalld相关命令详细介绍 的全部内容, 来源链接: utcz.com/z/337174.html

回到顶部