Linux關閉防火牆 開放埠

2021-10-07 19:00:38 字數 2400 閱讀 3974

linux的網路可以ping通,但是linux啟動的應用如tomcat / nginx等都無法訪問?

問題分析:

解決思路:

預設linux中的防火牆會關閉埠不允許訪問,但是可以ping的通linux的位址,所以想要訪問需要配置埠開放或者關閉防火牆。

centos 6 處理方法

//臨時關閉

service iptables stop

//禁止開機啟動

chkconfig iptables off

centos 7 處理方法

centos 7版本以後防火牆預設使用firewalld,所以centos 7 防火牆命令和centos 6 存在差異。

//臨時關閉

systemctl stop firewalld

//禁止開機啟動

systemctl disable firewalld

removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

removed symlink /etc/systemd/system/dbus-org.fedoraproject.firewalld1.service.

如果安裝了iptables-service選擇方案

//安裝ip服務

yum install -y iptables-services

//關閉防火牆

service iptables stop

redirecting to /bin/systemctl stop iptables.service

//檢查防火牆狀態

service iptables status

redirecting to /bin/systemctl status iptables.service

iptables.service - ipv4 firewall with iptables

loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)

active: inactive (dead)

防火牆相關命令

1、檢視防火牆狀態 : systemctl status firewalld.service

注:active是綠的running表示防火牆開啟

2、關閉防火牆 :systemctl stop firewalld.service

3、開機禁用防火牆自啟命令 :systemctl disable firewalld.service

4、啟動防火牆 :systemctl start firewalld.service

5、防火牆隨系統開啟啟動 : systemctl enable firewalld.service

6、重啟防火牆 : firewall-cmd --reload

埠開放命令

1、查詢已經開放的埠 :firewall-cmd --list-port

2、查詢某個埠是否開放 :firewall-cmd --query-port=80/tcp

3、開啟埠 :firewall-cmd --zone=public --add-port=80/tcp --permanent

注:可以是乙個埠範圍,如1000-2000/tcp

4、移除埠 :firewall-cmd --zone=public --remove-port=80/tcp --permanent

5、命令含義:

--zone #作用域

--add-port=80/tcp #新增埠,格式為:埠/通訊協議

--remove-port=80/tcp #移除埠,格式為:埠/通訊協議

--permanent #永久生效,沒有此引數重啟後失效

* 啟動:./apache-tomcat-8.5.50/bin/startup.sh

* 暫停:./apache-tomcat-8.5.50/bin/shutdown.sh

進入nginx目錄執行./configure命令

執行make命令

執行make install命令,執行完畢後在/usr/local/下會有乙個nginx目錄

啟動: cd nginx/sbin ./nginx

重啟:./nginx -s stop

Linux開放埠 關閉防火牆操作

1.1 通過systemctl status firewalld檢視firewalld狀態,發現當前是dead狀態,即防火牆未開啟。systemctl status firewalld1.2 通過systemctl start firewalld開啟防火牆,沒有任何提示即開啟成功 systemctl...

Linux防火牆的關閉或埠的開放

1.永久性生效 開啟 chkconfig iptables on 關閉 chkconfig iptables off 2.即時生效,重啟後失效 開啟 service iptables start 關閉 service iptables stop 3.檢視防火牆狀態 service iptables ...

Linux 防火牆永久開放埠

以下是linux開啟埠命令的使用方法。nc lp 23 開啟23埠,即telnet netstat an grep 23 檢視是否開啟23埠 經驗驗證,ok!只是,好像,linux開啟埠命令每乙個開啟的埠,都需要有相應的監聽程式才可以,這個有待改進!以上是linux開啟埠命令的使用方法。vi etc...