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
命令含義:
主站蜘蛛池模板: 新津县| 连平县| 宜城市| 凤庆县| 宁强县| 南召县| 高阳县| 顺昌县| 北宁市| 武陟县| 永川市| 瑞昌市| 宝丰县| 汶上县| 蒙城县| 文水县| 申扎县| 徐闻县| 隆化县| 湖州市| 任丘市| 东阿县| 甘德县| 农安县| 婺源县| 从化市| 长乐市| 东台市| 嘉鱼县| 简阳市| 柞水县| 焦作市| 博乐市| 余干县| 时尚| 泸州市| 天等县| 明光市| 综艺| 雅江县| 南江县|