Centos關閉防火牆

Centos關閉防火牆 CentOS6.5查看防火牆的狀態: 1 [linuxidc@localhost ~]$service iptable status [linuxidc@localhost ~]$service iptable status Redirecting to /bin/systemctl status iptable.service ● iptable.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 --state not running 檢查防火牆的狀態: 從centos7開始使用systemctl來管理服務和程序,包括了service和chkconfig。 [root@localhost ~]#systemctl list-unit-files|grep firewalld.service --防火牆處於關閉狀態 firewalld.service disabled [root@localhost ~]#systemctl status firewalld.service 關閉防火牆: 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 #重啓firewall systemctl stop firewalld.service #中止firewall systemctl 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必須從新設置一下 一、直接關閉防火牆 systemctl stop firewalld.service #中止firewall systemctl disable firewalld.service #禁止firewall開機啓動 二、設置 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
相關文章
相關標籤/搜索