一、基本操作

#启动防火墙
service iptables start
#停止防火墙
service iptables stop
#重启防火墙
service iptables restart
#查询防火墙运行等状态信息
service iptables status
#永久关闭防火墙
chkconfig iptables off
#永久关闭防火墙之后要启用
chkconfig iptables on
#保存对防火墙的设置
serivce iptables save
二、往防火墙添加规则
1)、直接编辑/etc/sysconfig/iptables
2)、通过命令进行添加
开放8080端口
#入栈规则
iptables -A  INPUT    -p tcp --dport 8080 -j ACCEPT
#出栈规则
iptables -A OUTPUT -p tcp --sport 8080 -j ACCEPT
禁止某个IP访问
iptables -A INPUT -p tcp -s 192.168.1.2 -j DROP
删除规则
iptables -D INPUT 2   #删除INPUT链编号为2的规则

参数讲解:
-A 添加一条规则
-p 指定协议,我们常用的tcp 协议,当然也有udp,例如53端口的DNS
--dport 进入端口,当数据从外部进入服务器为目标端口
--sport 出入端口,数据从服务器出去,则为数据源端口使用 
-j 就是指定是 ACCEPT 接收,或者 DROP 不接收
-s 指定来源IP等(如192.168.1.2)

具体看iptables --help
Usage: iptables -[ACD] chain rule-specification [options]
             iptables -I chain [rulenum] rule-specification [options]
             iptables -R chain rulenum rule-specification [options]
             iptables -D chain rulenum [options]
             iptables -[LS] [chain [rulenum]] [options]
             iptables -[FZ] [chain] [options]
             iptables -[NX] chain
             iptables -E old-chain-name new-chain-name
             iptables -P chain target [options]
             iptables -h (print this help information)
Commands:
Either long or short options are allowed.
  --append  -A chain Append to chain
  --check     -C chain Check for the existence of a rule
  --delete     -D chain Delete matching rule from chain
  --delete     -D chain rulenum                  Delete rule rulenum (1 = first) from chain
  --insert      -I    chain [rulenum]                Insert in chain as rulenum (default 1=first)
  --replace   -R   chain rulenum     Replace rule rulenum (1 = first) in chain
  --list           -L    [chain [rulenum]]     List the rules in a chain or all chains
  --list-rules -S    [chain [rulenum]]             Print the rules in a chain or all chains
  --flush        -F    [chain]                      Delete all rules in  chain or all chains
  --zero        -Z    [chain [rulenum]]      Zero counters in chain or all chains
  --new        -N    chain                      Create a new user-defined chain
  --delete  -chain   -X [chain]              Delete a user-defined chain
  --policy     -P     chain target              Change policy on chain to target
  --rename-chain            
                   -E     old-chain new-chain       Change chain name, (moving any references)
Options:
[!] --proto -p proto protocol: by number or name, eg. `tcp'
[!] --source    -s address[/mask][...]        source specification
[!] --destination -d address[/mask][...]        destination specification
[!] --in-interface -i input name[+]        network interface name ([+] for wildcard)
    --jump            -j target        target for rule (may load target extension)
    --goto            -g chain                               jump to chain with no return
   --match   -m match        extended match (may load extension)
   --numeric   -n                                numeric output of addresses and ports
[!] --out-interface -o output name[+]        network interface name ([+] for wildcard)
  --table           -t table                                table to manipulate (default: `filter')
  --verbose   -v                                verbose mode
  --line-numbers                                print line numbers when listing
  --exact          -x                                expand numbers (display exact values)
[!] --fragment  -f                                match second or further fragments only
  --modprobe=<command>                try to insert modules using this command
  --set-counters PKTS BYTES                set the counter during insert/append
[!] --version -V                                print package version.






 







iptables基本操作的更多相关文章

  1. Linux 防火墙 iptables基本操作

    1:临时性关闭开启防火墙,重启后失效开启service iptables start关闭service iptables stop/etc/rc.d/init.d/iptables stop 2:永久 ...

  2. Linux iptables 防火墙详解

    0x00 iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. netfilter 组件也称为内核空间,是内核的一部分,由一些 ...

  3. 防火墙之netfailt、iptables详解

    [TOC] Iptables入门 # 1.iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. netfilter 组件也称为 ...

  4. linux中iptables的用法

    iptables基本操作笔记 一.基本操作 #启动防火墙 service iptables start #停止防火墙 service iptables stop #重启防火墙 service ipta ...

  5. iptables防火墙简介

    原文地址:http://drops.wooyun.org/tips/1424 一.iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组 ...

  6. Iptables入门教程

    转自:http://drops.wooyun.org/tips/1424 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. netfilter ...

  7. linux防火墙 基础知识

    转 http://drops.wooyun.org/tips/1424 iptables介绍 linux的包过滤功能,即linux防火墙,它由netfilter 和 iptables 两个组件组成. ...

  8. iptables中增加/删除/查询/修改的基本操作

    虽然在Ubuntu使用了UFW来简化iptables的操作,但是UFW只针对防火墙方面,转发方面没有涉及,所以要弄懂其中的原理,还是必须回归到iptables中.CentOS也是如此.下面是针对ipt ...

  9. iptables防火墙--------基本操作

    查看规则 查看filter表中的规则 $ iptables -t filter -L 使用-t选项,指定要操作的表.使用-L 选项,查看-t选项对应表的规则,-L 选项的意思是,列出规则. ps : ...

随机推荐

  1. win7激活

    应亲戚要求,装了次win7系统,重新删除分区,格盘,重新划分好分区.完毕.发现系统分区全自动变成动态磁盘.使用win7激活工具时,注意选择使用 小马通用版激活工具. 动态磁盘 稍后解释 小马工具

  2. 两分钟了解REACTIVEX

    可能在之前,你就已经看过这篇响应式编程的入门.什么?太长?好吧,这都没关系,Rx并不难,你甚至可以自己实现一个这样的框架. 知道数组吧?你当然知道,这就是: [ 14, 9, 5, 2, 10, 13 ...

  3. MPU9250调试

    MPU9250 芯片概述 MPU9250芯片是一个9轴姿态传感芯片,其中包含了3轴加速度传感器.3轴角速度传感器以及三轴磁力计. 其本质上是MPU6050芯片+AK8963. 可以获取传感芯片的加速度 ...

  4. jquery.idTabs使用方法

    idTabs是基于Jquery编写封装的一个插件,主要用于实现选项卡功能,它操作简单,只需到官网:http://www.sunsean.com/idTabs/下载插件JS脚本文件,并引用到网站中即可 ...

  5. 一篇通俗易懂的讲解OpenGL ES的文章

    电脑或者手机上做图像处理有很多方式,但是目前为止最高效的方法是有效地使用图形处理单元,或者叫 GPU.你的手机包含两个不同的处理单元,CPU 和 GPU.CPU 是个多面手,并且不得不处理所有的事情, ...

  6. 淘宝API开发系列---阿里.聚石塔.开放平台的使用

    好久没有继续跟进淘宝的API使用了,有很多做相关应用的同行都来咨询,很多都因为自己开发工作比较忙而没有来得及好的处理,前几天,有一个朋友叫帮忙指导如何使用淘宝API,由于原来有一些成熟的例子应用,因此 ...

  7. Winform开发框架重构总结

    最近一直致力于Winform开发框架的重构工作,因为发现要维护传统Winform开发框架.WCF开发框架.混合式开发框架,以及相关的模块,包括权限管理.字典管理模块.附件管理.人员管理等一些辅助模块, ...

  8. js获取浏览器当前窗口的高度长度

    js获取浏览器可见区域(不包括标题栏.地址栏.收藏夹栏状态栏等额外区域,仅为页面呈现区域)的高度和宽度宽度:document.documentElement.clientWidth高度:documen ...

  9. JavaScript执行顺序分析

    之前从JavaScript引擎的解析机制来探索JavaScript的工作原理,下面我们以更形象的示例来说明JavaScript代码在页面中的执行顺序.如果说,JavaScript引擎的工作机制比较深奥 ...

  10. java之内的工具分享,附带下载链接,方便以后自己寻找

    class反编译工具:http://pan.baidu.com/s/1geYvX5L redis客户端工具:http://pan.baidu.com/s/1eRJ4ThC mysql客户端-[mysq ...