linux - 防火墙操作

对防火墙的操作是linux系统很常用的命令。

  1. 查看防火墙状态

systemctl status firewalld

[root@s201 river]# systemctl status firewalld
[0m firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-12-17 21:51:19 CST; 10s ago
     Docs: man:firewalld(1)
 Main PID: 70576 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           70576 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Dec 17 21:51:19 s201 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 17 21:51:19 s201 systemd[1]: Started firewalld - dynamic firewall daemon.
[

2. 临时关闭防火墙命令。重启电脑后,无效

systemctl stop firewalld

[root@s201 river]# systemctl stop firewalld
[root@s201 river]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 17 21:51:19 s201 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 17 21:51:19 s201 systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 17 21:52:39 s201 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 17 21:52:40 s201 systemd[1]: Stopped firewalld - dynamic firewall daemon.
  1. 临时打开防火墙命令。重启电脑后,无效
    systemctl start firewalld
[root@s201 river]# systemctl start firewalld
[root@s201 river]# systemctl status firewalld
[0m firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-12-17 21:56:22 CST; 5s ago
     Docs: man:firewalld(1)
 Main PID: 70925 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           70925 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Dec 17 21:56:22 s201 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 17 21:56:22 s201 systemd[1]: Started firewalld - dynamic firewall daemon.
  1. 永久关闭防火墙命令。重启后,有效。

systemctl disable firewalld

  1. 永久打开防火墙命令。重启后,有效。
    systemctl enable firewalld
[root@s201 river]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
    原文作者:良人与我
    原文地址: https://www.jianshu.com/p/cd2429cfd26d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞