Linux關閉防火牆


Centos 6.x版本 iptables

查看防火牆狀態:service iptables status

iptables:Firewall is not runing. 說明防火牆沒有開啟

開啟防火牆:service iptables start

關閉防火牆:service iptables stop

 

 

Centos 7版本 firewall

查看當前防火牆狀態:systemctl status firewalld.service

執行后可以看到綠色字樣標注的“active(running)”,說明防火牆是開啟狀態

 

關閉防火牆命令:systemctl stop firewalld.service

關閉后,使用命令systemctl status firewalld.service

可以看到,disavtive(dead)的字樣,說明防火牆已經關閉

 

開啟防火牆:systemctl start firewalld.service

 

怎么設置才能永久關閉防火牆呢?

關閉開機自啟動,禁止防火牆服務器:systemctl disable firewalld.service

 

開啟開機啟動:systemctl enable firewalld.service

 

CentOS7 默認使用firewalld防火牆,如果想換回iptables防火牆,可關閉firewalld並安裝iptables。

安裝iptables-services

yum install iptables-services

 

修改防火牆配置文件

vi /etc/sysconfig/iptables

 

默認的文件為:

在修改之前使用telnet命令查看端口是否開放。

1.啟動telnet。控制面板-->程序和功能-->打開或關閉windows功能-->勾選Telnet的兩個選項。
2.打開cmd窗口,輸入telnet,如果端口關閉或者無法連接,則顯示不能打開到主機的鏈接,鏈接失敗;端口打開的情況下,鏈接成功,則進入telnet頁面(全黑的),證明端口可用。

(1)telnet IP 端口。

(2)telnet 域名 端口。

 

 添加端口80、8080、3306、3690端口:

 esc :wq! 退出保存修改。

注意:添加在端口22上面或者下面,不要放在最后,不然不起作用。

 

 重啟防火牆使配置生效

systemctl restart iptables.service

剛剛yum install iptables.service之后系統如果沒有重啟,iptables.service是找不到的,會報unit not fount。耽誤時間的小坑!

設置防火牆開機啟動:

systemctl enable iptables.service

 

Linux 防火牆及開放端口管理

linux開啟端口

linux系統下如何打開端口

Linux關閉防火牆


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM