国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

詳解centos6和centos7防火墻的關閉

2024-09-01 13:49:55
字體:
來源:轉載
供稿:網友

CentOS6.5查看防火墻的狀態:

[zh@localhost ~]$service iptable status 

顯示結果:

[zh@localhost ~]$service iptable statusRedirecting to /bin/systemctl status iptable.serviceiptable.service  Loaded: not-found (Reason: No such file or directory)  Active: inactive (dead)  --表示防火墻已經關閉 

 CentOS 6.5關閉防火墻

[root@localhost ~]#servcie iptables stop           --臨時關閉防火墻[root@localhost ~]#chkconfig iptables off          --永久關閉防火墻 

CentOS 7.2關閉防火墻

CentOS 7.0默認使用的是firewall作為防火墻,這里改為iptables防火墻步驟。

firewall-cmd --state #查看默認防火墻狀態(關閉后顯示notrunning,開啟后顯示running)

[root@localhost ~]#firewall-cmd --statenot running 

 檢查防火墻的狀態:

從centos7開始使用systemctl來管理服務和程序,包括了service和chkconfig。

[root@localhost ~]#systemctl list-unit-files|grep firewalld.service      --防火墻處于關閉狀態firewalld.service              disabled 

或者

[root@localhost ~]#systemctl status firewalld.servicefirewalld.service - firewalld - dynamic firewall daemon  Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)  Active: inactive (dead) 

 關閉防火墻:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動

[root@localhost ~]#systemctl stop firewalld.service[root@localhost ~]#systemctl disable firewalld.service 
啟動一個服務:systemctl start firewalld.service關閉一個服務:systemctl stop firewalld.service重啟一個服務:systemctl restart firewalld.service顯示一個服務的狀態:systemctl status firewalld.service在開機時啟用一個服務:systemctl enable firewalld.service在開機時禁用一個服務:systemctl disable firewalld.service查看服務是否開機啟動:systemctl is-enabled firewalld.service;echo $?查看已啟動的服務列表:systemctl list-unit-files|grep enabled 

Centos 7 firewall 命令:

查看已經開放的端口:

firewall-cmd --list-ports

開啟端口

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

命令含義:

–zone #作用域

–add-port=80/tcp #添加端口,格式為:端口/通訊協議

–permanent #永久生效,沒有此參數重啟后失效

重啟防火墻

firewall-cmd --reload #重啟firewallsystemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall開機啟動firewall-cmd --state #查看默認防火墻狀態(關閉后顯示notrunning,開啟后顯示running)

CentOS 7 以下版本 iptables 命令

如要開放80,22,8080 端口,輸入以下命令即可

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

然后保存:

/etc/rc.d/init.d/iptables save

查看打開的端口:

/etc/init.d/iptables status

關閉防火墻

1) 永久性生效,重啟后不會復原

開啟: chkconfig iptables on

關閉: chkconfig iptables off

2) 即時生效,重啟后復原

開啟: service iptables start

關閉: service iptables stop

查看防火墻狀態: service iptables status 

下面說下CentOS7和6的默認防火墻的區別

CentOS 7默認使用的是firewall作為防火墻,使用iptables必須重新設置一下

1、直接關閉防火墻

systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall開機啟動

2、設置 iptables service

yum -y install iptables-services

如果要修改防火墻配置,如增加防火墻端口3306

vi /etc/sysconfig/iptables 

增加規則

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重啟防火墻使配置生效systemctl enable iptables.service #設置防火墻開機啟動

最后重啟系統使設置生效即可。

systemctl start iptables.service #打開防火墻systemctl stop iptables.service #關閉防火墻

解決主機不能訪問虛擬機CentOS中的站點

前陣子在虛擬機上裝好了CentOS6.2,并配好了apache+php+mysql,但是本機就是無法訪問。一直就沒去折騰了。 

具體情況如下

1. 本機能ping通虛擬機

2. 虛擬機也能ping通本機

3.虛擬機能訪問自己的web

4.本機無法訪問虛擬機的web 

后來發現是防火墻將80端口屏蔽了的緣故。 

檢查是不是服務器的80端口被防火墻堵了,可以通過命令:telnet server_ip 80 來測試。

解決方法如下:

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 

然后保存:

/etc/rc.d/init.d/iptables save 

重啟防火墻

/etc/init.d/iptables restart 

CentOS防火墻的關閉,關閉其服務即可:

查看CentOS防火墻信息:/etc/init.d/iptables status

關閉CentOS防火墻服務:/etc/init.d/iptables stop

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 斗六市| 台南县| 新兴县| 桑日县| 敦化市| 大渡口区| 滦平县| 阿荣旗| 会东县| 高清| 肥东县| 明溪县| 含山县| 郑州市| 丹江口市| 滨州市| 邯郸市| 弋阳县| 江口县| 海南省| 镇江市| 彰化市| 澄迈县| 奎屯市| 汝阳县| 葵青区| 上思县| 平乡县| 阳谷县| 玛沁县| 达尔| 凤翔县| 石嘴山市| 科技| 温泉县| 平阴县| 柘城县| 申扎县| 肇州县| 天门市| 夏河县|