---
title: "用命令行方式关闭CentOS防火墙"
author: "junmail"
date: "2015-11-11T11:40:38Z"
tags: []
categories: ["操作系统"]
slug: "centos"
draft: false
lastmod: "2015-11-11T11:40:38Z"
id: 2256130
url: "https://dbajun.iteye.com/blog/2256130"
---

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

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

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

重启计算机后，防火墙默认已经开放了80和22两个端口。

 

临时性的完全关闭防火墙，可以不重启机器：

#/etc/init.d/iptables status                ## 查看防火墙状态

#/etc/init.d/iptables stop                    ## 本次关闭防火墙

#/etc/init.d/iptables restart                ## 重启防火墙

永久性关闭防火墙：

#chkconfig --level 35 iptables off   ## 注意中间的是两个英式小短线；重启