1. 程式人生 > >CentOS 7.0 防火墻操作

CentOS 7.0 防火墻操作

proto local apr asq -o ble das top ora

CentOS 7.0默認使用的是firewall作為防火墻,之前版本是使用iptables。
所以在CentOS 7執行下面命令是無法查看防火墻狀態的。

[[email protected] ~]# service iptables status
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.

1
2
3
4

查看防火墻是否關閉

firewall-cmd –state

[[email protected] ~]# firewall-cmd --state

not running
[[email protected] ~]#

1
2
3

開啟防火墻

[[email protected] ~]# systemctl start firewalld
[[email protected] ~]# firewall-cmd --state
running
[[email protected] ~]#

1
2
3
4
5

關閉防火墻

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# firewall-cmd --state

not running
[[email protected] ~]#

1
2
3
4
5

禁止firewall開機啟動

[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

1
2
3

這樣設置的話,下次重啟開機的時候就會禁止firewall的啟動,即關閉狀態。
設置firewall開機啟動

[[email protected] ~]# 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.

1
2
3
4

這樣設置之後,開機就會自動開啟防火墻。
顯示防火墻應用列表

[[email protected] ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

[[email protected] ~]# firewall-cmd --add-service=ftp
success
[[email protected] ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

[[email protected] ~]#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

使用firewall-cmd --add-service=ftp 之後,列表顯示出多了一個ftp服務
---------------------
作者:黃寶康
來源:CSDN
原文:https://blog.csdn.net/huangbaokang/article/details/79923382
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

CentOS 7.0 防火墻操作