自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

CentOS 7上的FirewallD簡(jiǎn)明指南

運(yùn)維 系統(tǒng)運(yùn)維
FirewallD 是 CentOS 7 服務(wù)器上默認(rèn)可用的防火墻管理工具。基本上,它是 iptables 的封裝,有圖形配置工具 firewall-config 和命令行工具 firewall-cmd。使用 iptables 服務(wù),每次改動(dòng)都要求刷新舊規(guī)則,并且從 /etc/sysconfig/iptables 讀取新規(guī)則,然而 firewalld 只應(yīng)用改動(dòng)了的不同部分。

CentOS 7上的FirewallD簡(jiǎn)明指南

FirewallD 是 CentOS 7 服務(wù)器上默認(rèn)可用的防火墻管理工具?;旧?,它是 iptables 的封裝,有圖形配置工具 firewall-config 和命令行工具 firewall-cmd。使用 iptables 服務(wù),每次改動(dòng)都要求刷新舊規(guī)則,并且從 /etc/sysconfig/iptables 讀取新規(guī)則,然而 firewalld 只應(yīng)用改動(dòng)了的不同部分。

FirewallD 的區(qū)域(zone)

FirewallD 使用服務(wù)(service) 和區(qū)域(zone)來(lái)代替 iptables 的規(guī)則(rule)和鏈(chain)。

默認(rèn)情況下,有以下的區(qū)域(zone)可用:

  • drop – 丟棄所有傳入的網(wǎng)絡(luò)數(shù)據(jù)包并且無(wú)回應(yīng),只有傳出網(wǎng)絡(luò)連接可用。
  • block — 拒絕所有傳入網(wǎng)絡(luò)數(shù)據(jù)包并回應(yīng)一條主機(jī)禁止的 ICMP 消息,只有傳出網(wǎng)絡(luò)連接可用。
  • public — 只接受被選擇的傳入網(wǎng)絡(luò)連接,用于公共區(qū)域。
  • external — 用于啟用了地址偽裝的外部網(wǎng)絡(luò),只接受選定的傳入網(wǎng)絡(luò)連接。
  • dmz — DMZ 隔離區(qū),外部受限地訪問內(nèi)部網(wǎng)絡(luò),只接受選定的傳入網(wǎng)絡(luò)連接。
  • work — 對(duì)于處在你工作區(qū)域內(nèi)的計(jì)算機(jī),只接受被選擇的傳入網(wǎng)絡(luò)連接。
  • home — 對(duì)于處在你家庭區(qū)域內(nèi)的計(jì)算機(jī),只接受被選擇的傳入網(wǎng)絡(luò)連接。
  • internal — 對(duì)于處在你內(nèi)部網(wǎng)絡(luò)的計(jì)算機(jī),只接受被選擇的傳入網(wǎng)絡(luò)連接。
  • trusted — 所有網(wǎng)絡(luò)連接都接受。

要列出所有可用的區(qū)域,運(yùn)行:

  1. # firewall-cmd --get-zones 
  2. work drop internal external trusted home dmz public block 

列出默認(rèn)的區(qū)域 :

  1. # firewall-cmd --get-default-zone 
  2. public 

改變默認(rèn)的區(qū)域 :

  1. # firewall-cmd --set-default-zone=dmz 
  2. # firewall-cmd --get-default-zone 
  3. dmz 

FirewallD 服務(wù)

FirewallD 服務(wù)使用 XML 配置文件,記錄了 firewalld 服務(wù)信息。

列出所有可用的服務(wù):

  1. # firewall-cmd --get-services 
  2. amanda-client amanda-k5-client bacula bacula-client ceph ceph-mon dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp smtps snmp snmptrap squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server 

XML 配置文件存儲(chǔ)在 /usr/lib/firewalld/services/ 和 /etc/firewalld/services/ 目錄下。

用 FirewallD 配置你的防火墻

作為一個(gè)例子,假設(shè)你正在運(yùn)行一個(gè) web 服務(wù)器,SSH 服務(wù)端口為 7022 ,以及郵件服務(wù),你可以利用 FirewallD 這樣配置你的服務(wù)器:

首先設(shè)置默認(rèn)區(qū)為 dmz。

  1. # firewall-cmd --set-default-zone=dmz 
  2. # firewall-cmd --get-default-zone 
  3. dmz 

為 dmz 區(qū)添加持久性的 HTTP 和 HTTPS 規(guī)則:

  1. # firewall-cmd --zone=dmz --add-service=http --permanent 
  2. # firewall-cmd --zone=dmz --add-service=https --permanent 

開啟端口 25 (SMTP) 和端口 465 (SMTPS) :

  1. firewall-cmd --zone=dmz --add-service=smtp --permanent 
  2. firewall-cmd --zone=dmz --add-service=smtps --permanent 

開啟 IMAP、IMAPS、POP3 和 POP3S 端口:

  1. firewall-cmd --zone=dmz --add-service=imap --permanent 
  2. firewall-cmd --zone=dmz --add-service=imaps --permanent 
  3. firewall-cmd --zone=dmz --add-service=pop3 --permanent 
  4. firewall-cmd --zone=dmz --add-service=pop3s --permanent 

因?yàn)閷?SSH 端口改到了 7022,所以要移除 ssh 服務(wù)(端口 22),開啟端口 7022:

  1. firewall-cmd --remove-service=ssh --permanent 
  2. firewall-cmd --add-port=7022/tcp --permanent 

要應(yīng)用這些更改,我們需要重新加載防火墻:

  1. firewall-cmd --reload 

最后可以列出這些規(guī)則:

  1. # firewall-cmd –list-all 
  2. dmz 
  3. target: default 
  4. icmp-block-inversion: no 
  5. interfaces: 
  6. sources: 
  7. services: http https imap imaps pop3 pop3s smtp smtps 
  8. ports: 7022/tcp 
  9. protocols: 
  10. masquerade: no 
  11. forward-ports: 
  12. sourceports: 
  13. icmp-blocks: 
  14. rich rules: 

譯者簡(jiǎn)介:

Locez 是一個(gè)喜歡技術(shù),喜歡折騰的 Linuxer,靠著對(duì) Linux 的興趣自學(xué)了很多 Linux 相關(guān)的知識(shí),并且志在于為 Linux 在中國(guó)普及出一份力。

責(zé)任編輯:龐桂玉 來(lái)源: Linux中國(guó)
相關(guān)推薦

2017-12-04 10:03:45

2017-01-05 13:41:56

2016-02-01 10:12:22

網(wǎng)頁(yè)設(shè)計(jì)移動(dòng)端

2021-02-07 09:57:54

正則表達(dá)式字符串Linux

2019-02-15 08:51:22

2022-04-28 18:24:36

CentOSLinux

2021-03-15 08:18:10

Web安全黑客漏洞

2024-03-01 20:28:54

CentOS 7文件操作search

2014-12-01 11:27:54

CentOS 7Docker

2017-05-03 14:00:00

LinuxCentOSElastic Sta

2020-08-28 11:20:01

CentOS7RocketMQ 4.運(yùn)維

2022-12-02 11:37:47

2023-02-14 17:11:50

開源鴻蒙刷機(jī)指南

2019-04-08 09:00:00

CentOS 7ElasticsearLinux

2024-03-07 12:45:27

PyTorch

2015-12-29 13:59:53

Ubuntu 15.0CentOS 7Android Stu

2015-09-10 11:38:37

iTOPCentOS開源

2015-12-11 13:16:10

CentOS 7Redis服務(wù)器

2020-09-15 09:48:41

PHP

2010-12-08 11:11:15

Windows 7
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)