濮阳杆衣贸易有限公司

主頁 > 知識庫 > 淺談簡單使用CentOS7防火墻及開放端口

淺談簡單使用CentOS7防火墻及開放端口

熱門標(biāo)簽:河南省鄭州市地圖標(biāo)注 地圖標(biāo)注需要提交啥資料入駐 新鄉(xiāng)人工智能電話機(jī)器人加盟 昆明外呼系統(tǒng) 七大洲地圖標(biāo)注 臨汾電銷機(jī)器人費(fèi)用 福州呼叫中心外呼系統(tǒng)哪家好 地圖標(biāo)注w是什么方向 400電話申請找哪家公司

概述(官方有更為詳細(xì)的說明哦)

Firewalld提供動(dòng)態(tài)管理的防火墻,支持網(wǎng)絡(luò)/防火墻區(qū)域,用于定義網(wǎng)絡(luò)連接或接口的信任級別。它支持IPv4,IPv6防火墻設(shè)置,以太網(wǎng)橋和IP集。運(yùn)行時(shí)和永久配置選項(xiàng)分開。它還為服務(wù)或應(yīng)用程序提供了直接添加防火墻規(guī)則的接口。

既然是簡單使用, 那必須教會(huì)你怎么查看防火墻狀態(tài), 以及防火墻的關(guān)閉和開啟之類的, 我們都知道那既然防火墻都開啟了, 那么它必定是有一些端口的限制, 不能說你想通過哪些端口就通過哪些端口, 就能訪問到我們的主機(jī)(也就是服務(wù)器了), 換句說話, 我開放了哪些端口, 你才可以通過我開放的這些端口對我的主機(jī)進(jìn)行訪問, 要不然我們還要防火墻干嘛, 誰想進(jìn)來就進(jìn)來(還是通過任意端口), 防火墻不就成了擺設(shè)不成, 說到防火墻要還要多說一句, 防火墻有軟件層面的和物理設(shè)置層面的(網(wǎng)絡(luò)內(nèi)的一臺專業(yè)物理設(shè)備), 那我們這里是所說的是軟件層面的防火墻也就是Firewalld, CentOS7以下版本普遍使用的軟件防火墻是Firewalld, 為什么說是CentOS7以下版本普遍使用的呢? 這是因?yàn)橹暗腃entOS版本都是使用的iptables防火墻, 那要往深處說, 這就要追溯到CentOS7的發(fā)展歷程及RedHad之間的關(guān)系啦, 扯遠(yuǎn)了哈, 我們使用防火墻的主要目的是對我們的主機(jī)進(jìn)行安全管理, 其中主要的一部分就是端口管理了!

查詢防火墻狀態(tài)

shell

# systemctl status firewalld

execute

[warnerwu@localhost ~]$ 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)

啟動(dòng)防火墻

注意:防火墻只有管理員或管理員用戶組有權(quán)限進(jìn)行管理操作, 普通用戶則不可以

shell

# systemctl start firewalld

execute

[root@localhost~]# systemctl start firewalld
[root@localhost~]#

你會(huì)發(fā)現(xiàn)什么也沒有, 玩 linux 或 osx 系統(tǒng)的小伙伴都知道, 沒有提示那就是最好的提示, 說明已經(jīng)成功啦, 有提示時(shí)則一會(huì)有問題哦

再次查看防火墻狀態(tài)

shell

# systemctl status firewalld

execute

[root@localhost ~]# sudo systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  Active: active (running) since 五 2018-09-07 00:04:55 CST; 5min ago
   Docs: man:firewalld(1)
 Main PID: 11339 (firewalld)
  CGroup: /system.slice/firewalld.service
      └─11339 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z systemd[1]: Starting firewalld - dynamic firewall daemon...
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z systemd[1]: Started firewalld - dynamic firewall daemon.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignorin...-time.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignori...-time.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6.
9月 07 00:04:55 izj6c3bcx7adgva5dda2e0z firewalld[11339]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignorin...-time.
Hint: Some lines were ellipsized, use -l to show in full.

嗯嗯, 你會(huì)發(fā)現(xiàn)在已經(jīng)在運(yùn)行啦, 就是這樣子哦, 還要多說一句, 那如果你對 CentOS7 或 RedHat7 足夠了解的話, 你會(huì)很熟悉 systemctl是個(gè)什么東東, 她呀, 就是系統(tǒng)服務(wù)管理工具, 是系統(tǒng)工具, 用來管理系統(tǒng)服務(wù)的, 就這么理解就可以不會(huì)錯(cuò)的! 之前的CentOS版本都是使用的 service 進(jìn)行系統(tǒng)服務(wù)管理的哦, 關(guān)于更多 systemctl 或 service 的信息請動(dòng)手 百度 或 Google, 我們簡單的說完了, 查看防火墻狀態(tài)以及怎么啟動(dòng)防火墻, 那我們的就來說說怎么來開放端口!

查看防火墻開放端口列表

防火墻的端口管理是通過 firewall-cmd 命令來進(jìn)行管理的哦, 這一點(diǎn)必須要明確, 也是你管理系統(tǒng)端口的關(guān)鍵所在, 嗯嗯, 是她, 是她, 就是她, 她就是這么的如此風(fēng)騷, 哈哈, 你拿她一點(diǎn)辦法都沒有, 不你可以把她玩的服服貼貼的, 什么呀!你想多了, 我什么也沒有說哦, 是你自己這樣想的~

shell

# firewall-cmd --list-all

execute

[root@localhost ~]# firewall-cmd --list-all
public
 target: default
 icmp-block-inversion: no
 interfaces:
 sources:
 services: ssh dhcpv6-client
 ports:
 protocols:
 masquerade: no
 forward-ports:
 source-ports:
 icmp-blocks:
 rich rules:

你會(huì)發(fā)現(xiàn)它如此空曠, 沒有任何開放端口, 嗯, 這是一臺新裝linux系統(tǒng), 你的也許會(huì)跟我這個(gè)一樣, 也許會(huì)不一樣, 這個(gè)要注意一下

添加開放端口到防火墻

比如我們讓80端口開放, 其它用戶可以訪問我的站點(diǎn)

shell

// Step1: 加入開放端口到配置文件

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

--zone=public 添加時(shí)區(qū)

--add-port=80/tcp 添加端口

--permanent 永久生效

// 加載防火墻新配置文件( 以 root 身份輸入以下命令,重新加載防火墻,并不中斷用戶連接,即不丟失狀態(tài)信息. )

firewall-cmd --reload

再次查看防火墻開放端口列表

shell

# firewall-cmd --list-all

execute

[root@localhost ~]# firewall-cmd --list-all
public
 target: default
 icmp-block-inversion: no
 interfaces:
 sources:
 services: ssh dhcpv6-client
 ports: 80/tcp
 protocols:
 masquerade: no
 forward-ports:
 source-ports:
 icmp-blocks:
 rich rules:

這次你會(huì)發(fā)現(xiàn) ports 對應(yīng)的多了一個(gè) 80/tcp, 那說明就已經(jīng)添加到了防火墻開放列表中了

1、firewalld的基本使用

啟動(dòng): systemctl start firewalld
關(guān)閉: systemctl stop firewalld
查看狀態(tài): systemctl status firewalld
開機(jī)禁用 : systemctl disable firewalld
開機(jī)啟用 : systemctl enable firewalld

2.systemctl是CentOS7的服務(wù)管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。

啟動(dòng)一個(gè)服務(wù):systemctl start firewalld.service
關(guān)閉一個(gè)服務(wù):systemctl stop firewalld.service
重啟一個(gè)服務(wù):systemctl restart firewalld.service
顯示一個(gè)服務(wù)的狀態(tài):systemctl status firewalld.service
在開機(jī)時(shí)啟用一個(gè)服務(wù):systemctl enable firewalld.service
在開機(jī)時(shí)禁用一個(gè)服務(wù):systemctl disable firewalld.service
查看服務(wù)是否開機(jī)啟動(dòng):systemctl is-enabled firewalld.service
查看已啟動(dòng)的服務(wù)列表:systemctl list-unit-files|grep enabled
查看啟動(dòng)失敗的服務(wù)列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看幫助: firewall-cmd --help
顯示狀態(tài): firewall-cmd --state
查看所有打開的端口: firewall-cmd --zone=public --list-ports
更新防火墻規(guī)則: firewall-cmd --reload
查看區(qū)域信息: firewall-cmd --get-active-zones
查看指定接口所屬區(qū)域: firewall-cmd --get-zone-of-interface=eth0
拒絕所有包:firewall-cmd --panic-on
取消拒絕狀態(tài): firewall-cmd --panic-off
查看是否拒絕: firewall-cmd --query-panic

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:紅河 鎮(zhèn)江 四川 股票 烏海 臨沂 岳陽 ???/a>

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《淺談簡單使用CentOS7防火墻及開放端口》,本文關(guān)鍵詞  淺談,簡單,使用,CentOS7,防火墻,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《淺談簡單使用CentOS7防火墻及開放端口》相關(guān)的同類信息!
  • 本頁收集關(guān)于淺談簡單使用CentOS7防火墻及開放端口的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    南和县| 安康市| 涪陵区| 广西| 巴里| 尚义县| 吉隆县| 太和县| 墨玉县| 义马市| 内江市| 从江县| 雷州市| 永德县| 娱乐| 石河子市| 威信县| 雅江县| 平顶山市| 永新县| 韶关市| 拉孜县| 南阳市| 凤冈县| 古蔺县| 桂阳县| 东莞市| 宁强县| 遵义县| 康保县| 土默特左旗| 成安县| 常宁市| 丰原市| 商洛市| 来安县| 繁峙县| 安岳县| 昌黎县| 天台县| 常德市|