CentOS7 查看和关闭系统防火墙
blank
blank
发布于 2019-03-14 / 440 阅读 / 0 评论 / 0 点赞

CentOS7 查看和关闭系统防火墙

检查防火墙当前状态

systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 四 2019-03-14 09:03:01 CST; 10min ago
     Docs: man:firewalld(1)
 Main PID: 9059 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─9059 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Active: active(running) 正在运行

停止防火墙 且 禁用开机启动

systemctl stop firewalld && systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

再次检查防火墙状态

systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 四 2019-03-14 09:15:35 CST; 2s ago
     Docs: man:firewalld(1)
  Process: 9059 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 9059 (code=exited, status=0/SUCCESS)
3月 14 09:02:57 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
3月 14 09:03:01 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
3月 14 09:15:35 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon. 

Active: inactive (dead) 已经停止

ps 防火墙常用命令

查看已经开放的端口:

firewall-cmd --list-ports

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含义: –zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议 –permanent #永久生效,没有此参数重启后失效

重启firewall

firewall-cmd --reload 

评论