centos6 防火墙iptables操作整理

本文涉及的产品
云防火墙,500元 1000GB
简介: 使用语句   前言:  iptables的启动文件位置再:  /etc/init.d/iptables , srevice iptables调用的就是这里的执行文件 查看防火墙状态   service iptables status 开启防火墙    service iptables sta...

使用语句

  前言:  iptables的启动文件位置再:  /etc/init.d/iptables , srevice iptables调用的就是这里的执行文件

  1. 查看防火墙状态   service iptables status
  2. 开启防火墙    service iptables start 
  3. 关闭防火墙  service iptables stop
  4. 永久关闭防火墙(开机不启动)  chkconfig iptables off     附:chkconfig使用方法
  5. 永久开启防火墙(开机启动)  chkconfig iptables on
  6. 查看防火墙状态  chkconfig --list iptables 
    1. 等级0表示:表示关机
    2. 等级1表示:单用户模式
    3. 等级2表示:无网络连接的多用户命令行模式
    4. 等级3表示:有网络连接的多用户命令行模式
    5. 等级4表示:不可用
    6. 等级5表示:带图形界面的多用户模式
    7. 等级6表示:重新启动
  7.   防火墙开放某个接口  附: 详细说明文档
    1. 查看防火墙当前设置,具体开发的端口号信息  /etc/init.d/iptables status
    2. 配置防火墙策略  vi /etc/sysconfig/iptables
      1.  例如我要开22,80,3306端口,4500到4600的所有端口
        # Firewall configuration written by system-config-firewall 
        # Manual customization of this file is not recommended. 
        *filter 
        :INPUT ACCEPT [0:0] 
        :FORWARD ACCEPT [0:0] 
        :OUTPUT ACCEPT [0:0] 
        -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT 
        -A INPUT -p icmp -j ACCEPT 
        -A INPUT -i lo -j ACCEPT 
        
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
        -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

        -A INPUT -m state –state NEW -m tcp -p tcp –dport 4500:4600 -j ACCEPT
        -A INPUT -j REJECT –reject-with icmp-host-prohibited 
        -A FORWARD -j REJECT –reject-with icmp-host-prohibited 
        COMMIT 
        

          保存退出

      2. 重启防火墙  service iptables restart

填坑笔记

  1. 启动防火墙时"iptables"no config file"错误 --- 未找到配置文件iptables。
    1. 新建一条规则     iptables -P OUTPUT ACCEPT
    2. 保存  service iptables save
    3. 再次启动防火墙  service iptables start
  2.   
目录
相关文章
|
18天前
|
机器学习/深度学习 安全 网络协议
Linux防火墙iptables命令管理入门
本文介绍了关于Linux防火墙iptables命令管理入门的教程,涵盖了iptables的基本概念、语法格式、常用参数、基础查询操作以及链和规则管理等内容。
178 73
|
2月前
|
网络协议 Linux 网络安全
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
在CentOS 7中,新引入了firewalld服务(防火墙),取代了CentOS 6之前的iptables服务(防火墙)。
入职必会-开发环境搭建39-Linux常用操作-Linux防火墙操作
|
1月前
|
存储 网络协议 Ubuntu
如何在 Ubuntu 14.04 上使用 Iptables 实现基本防火墙模板
如何在 Ubuntu 14.04 上使用 Iptables 实现基本防火墙模板
26 0
|
1月前
|
网络协议 Ubuntu Linux
Iptables 防火墙的工作原理
Iptables 防火墙的工作原理
18 0
|
4月前
|
XML 安全 Linux
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
|
4月前
|
Linux 网络安全
centos7如何关闭防火墙
centos7如何关闭防火墙
447 3
|
4月前
|
网络协议 Linux 网络安全
iptables 与 firewalld 防火墙
iptables 与 firewalld 防火墙
|
4月前
|
网络协议 Linux 网络安全
CentOS 7 防火墙指令
本文介绍了CentOS 7中管理防火墙`firewalld`的指令。
70 0
|
4月前
|
网络协议 Linux 网络安全
Linux(17)Centos5、6、7、8版本的防火墙常用命令
Linux(17)Centos5、6、7、8版本的防火墙常用命令
87 0
|
4月前
|
网络协议 Linux 网络安全
Centos7 防火墙策略rich-rule 限制ip访问-----图文详解
Centos7 防火墙策略rich-rule 限制ip访问-----图文详解
676 0