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
命令含義:
主站蜘蛛池模板: 壤塘县| 嘉峪关市| 新竹县| 洮南市| 牙克石市| 丹江口市| 三原县| 社会| 加查县| 株洲县| 仁怀市| 江川县| 军事| 肥乡县| 郧西县| 宝丰县| 微山县| 阳曲县| 东兰县| 鱼台县| 九龙城区| 天柱县| 古浪县| 江华| 迭部县| 丰都县| 九龙城区| 津南区| 息烽县| 永修县| 海兴县| 澄江县| 静乐县| 武定县| 维西| 尤溪县| 绥阳县| 广州市| 资源县| 衡东县| 双桥区|