亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄
Understanding Zones and Default Configuration
Opening Ports and Services
Managing Runtime and Permanent Settings
Working with Specific Zones
首頁 運(yùn)維 CentOS 如何在CentOS上使用firewalld-cmd配置防火墻?

如何在CentOS上使用firewalld-cmd配置防火墻?

Oct 12, 2025 am 04:24 AM

首先明確配置CentOS防火墻的核心是理解區(qū)域、服務(wù)和持久化設(shè)置,具體需掌握firewalld的zone劃分如public、internal等,使用firewall-cmd命令管理運(yùn)行時(shí)與永久規(guī)則,通過--add-service或--add-port開放服務(wù)端口,結(jié)合--permanent參數(shù)確保規(guī)則重啟生效,并在修改后執(zhí)行--reload應(yīng)用配置。

How to configure a firewall with firewalld-cmd on CentOS?

Configuring a firewall on CentOS using firewalld-cmd is straightforward once you understand the core concepts of zones, services, and runtime vs. permanent settings. firewalld uses dynamic zones to define trust levels for network connections, and you can manage rules with the firewall-cmd command-line tool.

Understanding Zones and Default Configuration

When you start firewalld, it assigns interfaces to zones based on predefined rules. Common zones include:

  • public: For public areas where you don’t trust other computers (default for most installations)
  • internal: For internal networks with some level of trust
  • home: For home networks
  • trusted: All traffic is accepted

To check the current active zone and assigned interfaces:

firewall-cmd --get-active-zones

To see the default zone:

firewall-cmd --get-default-zone

You can change the default zone with:

firewall-cmd --set-default-zone=internal

Opening Ports and Services

Instead of managing raw ports, firewalld allows you to enable predefined services (like http, ssh). To allow HTTP traffic in the current session:

firewall-cmd --add-service=http

To make this change permanent across reboots:

firewall-cmd --permanent --add-service=http

Then reload the firewall:

firewall-cmd --reload

If you need to open a custom port, such as TCP 8080:

firewall-cmd --add-port=8080/tcp
firewall-cmd --permanent --add-port=8080/tcp

Managing Runtime and Permanent Settings

By default, firewall-cmd applies changes only to the runtime configuration. These are lost after reboot unless made permanent.

To list all currently active settings:

firewall-cmd --list-all

To list permanent settings:

firewall-cmd --permanent --list-all

Always use --permanent when you want rules to persist. Remember to run --reload after making permanent changes to apply them to the running configuration.

Working with Specific Zones

If your system has multiple network interfaces, assign them to appropriate zones. For example, to add an interface eth1 to the internal zone:

firewall-cmd --zone=internal --add-interface=eth1

To allow SSH access only in the trusted zone:

firewall-cmd --zone=trusted --add-service=ssh
firewall-cmd --permanent --zone=trusted --add-service=ssh

You can also block all traffic in a zone by removing unwanted services or using rich rules for fine-grained control.

Basically, get familiar with zones, use services when possible, always consider the permanent flag, and reload when needed. That’s how you maintain a secure and functional firewall on CentOS with firewalld.

以上是如何在CentOS上使用firewalld-cmd配置防火墻?的詳細(xì)內(nèi)容。更多信息請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請(qǐng)聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Stock Market GPT

Stock Market GPT

人工智能驅(qū)動(dòng)投資研究,做出更明智的決策

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)

熱門話題

如何在CentOS上安裝Docker 如何在CentOS上安裝Docker Sep 23, 2025 am 02:02 AM

卸載舊版本Docker避免沖突,2.安裝yum-utils并添加官方Docker倉庫,3.安裝DockerCE、CLI和containerd,4.啟動(dòng)并啟用Docker服務(wù),5.運(yùn)行hello-world鏡像驗(yàn)證安裝成功,6.可選配置非root用戶運(yùn)行Docker。

如何在CentOS上解決網(wǎng)絡(luò)問題 如何在CentOS上解決網(wǎng)絡(luò)問題 Sep 17, 2025 am 01:14 AM

startbyCheckingNetwork InterfacestatuswithipAddrshow,Suseit'supandhasavalidip; ifDown,bringitupusitusiplinkSetup.verifyConnectivityBypingThegateway(findviaiproute | grepdefeault)

如何在CentOS上啟用SSH根登錄 如何在CentOS上啟用SSH根登錄 Sep 19, 2025 am 03:43 AM

sodrootpasswordwithsudopasswdroot,edit/ett/etc/ssh/sshd_configtosetpermitrootloginyesand andpasswordauthenticationyes,thenRestartSshviasudoSystemctLrestartsshd,testingnewaccessbebeforeclosingclosingcortentssession。

如何在CentOS上配置交換文件 如何在CentOS上配置交換文件 Sep 20, 2025 am 01:15 AM

createa2gbswapfileusingddif =/dev/zeroof =/swapfilebs = 1mcount = 2048.2.setpermissionswithChmod600/swapfile.3.formatasswapusemks wap/swapfile.4.enablewithswapon/swapfile.5.makepermanentbyadding/swapfilenoneswapsw00to/etc/fstab.6.optionallysetvm.swappines

如何在CentOS上清除百勝緩存 如何在CentOS上清除百勝緩存 Sep 21, 2025 am 02:50 AM

使用sudoyumcleanall清除所有緩存并用sudoyummakecache重建,可解決包問題并釋放磁盤空間。

如何解決CentOS上的YUM存儲(chǔ)庫錯(cuò)誤 如何解決CentOS上的YUM存儲(chǔ)庫錯(cuò)誤 Sep 18, 2025 am 04:41 AM

首先,checkInternetanddnsconnectivity disepingAndnslookup;如果flaged,更新/etc/etc/confwithvaliddnssservers.thencleanyumcachewith“ yumcleanall”,remove/var/var/cacke/cache/yum yum yum andregenerateMetAtaTavia“ yummakecececace,yummakakecache”

如何安裝讓我們?cè)贑entOS上加密SSL 如何安裝讓我們?cè)贑entOS上加密SSL Sep 25, 2025 am 03:22 AM

首先安裝EPEL源和certbot工具,然后根據(jù)Web服務(wù)器選擇對(duì)應(yīng)插件,運(yùn)行certbot獲取證書并自動(dòng)配置,最后設(shè)置cron任務(wù)實(shí)現(xiàn)每半年自動(dòng)續(xù)期,確保SSL證書持續(xù)有效。

如何在CentOS上安裝KVM 如何在CentOS上安裝KVM Sep 19, 2025 am 05:02 AM

檢查CPU虛擬化支持,確認(rèn)BIOS中已啟用;2.安裝KVM相關(guān)包并啟動(dòng)libvirtd服務(wù);3.驗(yàn)證模塊加載與服務(wù)狀態(tài),使用virt-install創(chuàng)建虛擬機(jī);4.可選配置橋接網(wǎng)絡(luò)以提升性能。

See all articles