Centos 7 防火墙 firewalld 相关基础命令

【注】在 Centos7 下默认的防火墙变成了 firewalld,而不再是之前的 iptables,如果买阿里云或者腾讯云的服务器的话一般是没有防火墙的需要自己进行安装。

【注】其实 firewalld 并不具备防火墙的功能,而是和 iptables 一样,他们两者仅仅是维护规则,真正起到防火墙作用的是 内核中的 netfilter

1. 安装 firewalld 防火墙

yum install firewalld

2. firewalld 基本命令

其实就是 systemctl 命令的使用,在 Centos 7 系统中推荐 systemctl 来代替 service

当然如果不习惯的话也可以继续使用 service,但是呢,其实命令还是会自动的重定向到 systemctl 并使用该命令。

# 查看状态
systemctl status firewalld
# OR
service firewalld status

# 启动
systemctl start firewalld
# OR
service firewalld start

# 停止运行
systemctl stop firewalld
# OR
service firewalld stop

# 禁止开机启动
systemctl disable firewalld

# 允许开机启动
systemctl enable firewalld

3. firewall-cmd 基本命令

【注】执行的时候需要 root 权限。

  • 获取 firewalld 的版本
    $ firewall-cmd --version #或 firewall-cmd -V
    0.8.2
    
  • 获取命令帮助文档
    $ firewall-cmd --help #或  firewall-cmd -h
    
  • 获取 firewalld 的状态
    $ firewall-cmd --state
    running  # 表示正在运行	
    

更多使用命令,不定期进行更新补充。。。

猜你喜欢

转载自blog.csdn.net/peng2hui1314/article/details/115790423