编辑文章 linux防火墙linux防火墙iptablesfirewall # 一、iptables防火墙 ## 1、基本操作 ### **查看防火墙状态** `service iptables status ` ### **查看iptables规则** `iptables -nvL` ### **停止防火墙** `service iptables stop ` ### **启动防火墙**`service iptables start ` ### 重启防火墙`service iptables restart` ### 永久关闭防火墙`chkconfig iptables off ` ### 永久关闭后重启`chkconfig iptables on` ## 2、开启80端口 `vim /etc/sysconfig/iptables` ### 加入如下代码 `-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT` 保存退出后重启防火墙 `service iptables restart` # 二、firewall防火墙 ### 1、查看firewall服务状态`systemctl status firewalld` 出现Active: active (running)切高亮显示则表示是启动状态。 出现 Active: inactive (dead)灰色表示停止,看单词也行。 ### 2、查看firewall的状态`firewall-cmd --state` ### 3、开启、重启、关闭、firewalld.service服务 #### 开启`service firewalld start` #### 重启`service firewalld restart` #### 关闭`service firewalld stop` ### 4、查看防火墙规则`firewall-cmd --list-all ` ### 5、查询、开放、关闭端口 ### 查询端口是否开放`firewall-cmd --query-port=8080/tcp` ##### 开放80端口`firewall-cmd --permanent --add-port=80/tcp` ##### 移除端口`firewall-cmd --permanent --remove-port=8080/tcp` #### 重启防火墙(修改配置后要重启防火墙)`firewall-cmd --reload` ### 参数解释 1、firwall-cmd:是Linux提供的操作firewall的一个工具; 2、--permanent:表示设置为持久; 3、--add-port:标识添加的端口; <h1>一、iptables防火墙</h1> <h2>1、基本操作</h2> <h3><strong>查看防火墙状态</strong> <code>service iptables status </code></h3> <h3><strong>查看iptables规则</strong> <code>iptables -nvL</code></h3> <h3><strong>停止防火墙</strong> <code>service iptables stop </code></h3> <h3><strong>启动防火墙</strong><code>service iptables start </code></h3> <h3>重启防火墙<code>service iptables restart</code></h3> <h3>永久关闭防火墙<code>chkconfig iptables off </code></h3> <h3>永久关闭后重启<code>chkconfig iptables on</code> </h3> <h2>2、开启80端口</h2> <p><code>vim /etc/sysconfig/iptables</code></p> <h3>加入如下代码</h3> <p><code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT</code></p> <p>保存退出后重启防火墙</p> <p><code>service iptables restart</code></p> <h1>二、firewall防火墙</h1> <h3>1、查看firewall服务状态<code>systemctl status firewalld</code></h3> <p>出现Active: active (running)切高亮显示则表示是启动状态。</p> <p>出现 Active: inactive (dead)灰色表示停止,看单词也行。</p> <h3>2、查看firewall的状态<code>firewall-cmd --state</code></h3> <h3>3、开启、重启、关闭、firewalld.service服务</h3> <h4>开启<code>service firewalld start</code></h4> <h4>重启<code>service firewalld restart</code></h4> <h4>关闭<code>service firewalld stop</code></h4> <h3>4、查看防火墙规则<code>firewall-cmd --list-all </code></h3> <h3>5、查询、开放、关闭端口</h3> <h3>查询端口是否开放<code>firewall-cmd --query-port=8080/tcp</code></h3> <h5>开放80端口<code>firewall-cmd --permanent --add-port=80/tcp</code></h5> <h5>移除端口<code>firewall-cmd --permanent --remove-port=8080/tcp</code></h5> <h4>重启防火墙(修改配置后要重启防火墙)<code>firewall-cmd --reload</code></h4> <h3>参数解释</h3> <p>1、firwall-cmd:是Linux提供的操作firewall的一个工具; 2、--permanent:表示设置为持久; 3、--add-port:标识添加的端口;</p> 标题: 分类: 请选择分类(必选) 博客 酷玩 分享 相册 标签: 按 Tab、回车或逗号把输入的文字变成标签;点 × 或在输入框为空时按退格删除;最多 8 个 封面图: 上传图片 建议尺寸 800x400,图片大小不超过 1MB 展开更多设置(关键词、摘要、转载、评论) 关键词: 摘要: 一、iptables防火墙 1、基本操作 查看防火墙状态 service iptables status 查看iptables规则 iptables -nvL 停止防火墙 service iptables stop 启动防火墙service ip... 选项: 是否转载 启用评论 勾选「是否转载」可标注文章来源,原文链接可留空。 正文: 保存修改