前言

在这两篇博文中已经具体分析了iptable的原理和在openwrt里面的实例

http://www.cnblogs.com/tanhangbo/p/4550455.html
http://www.cnblogs.com/tanhangbo/p/4518254.html

可以概括出iptables/Netfilter 这一套系统就是用户空间可控的在内核空间的一套钩子
下面看看iptables究竟能做什么。

NAT

  • 使用SNAT功能可以将内网IP转换为公网IP,实现在外部的Ethernet口上面

    • 封包出在post routing上面将内网ip转换为公网ip
    • 封包进在pre routing上面将公网ip转换为内网的ip
    • 注意到Netfilter会标记这个状态,不然回来的包会找不到源头。
  • 使用DNAT功能可以实现DMZ主机的功能,实现在外部的Ethernet口上面
    • 封包进在pre routing上面将公网ip转换为内网指定的DMZ主机的ip
    • 封包出去时在post routing上面将内网的数据包发送到对应的源主机。

防火墙

  • 可以根据ip、MAC地址、端口、协议来丢弃某些数据包,比如internet上面有人想连接到本机的SSH,那么对外部接口关闭SSH的端口22就可以起到一些作用。

负载均衡

注意到下面的选项:

  1. Thismodule matches every 'n'th packet
  2. --every value
  3. Match every 'value' packet
  4. [--counter num]
  5. Useinternal counter number 'num'.Defaultis'0'.
  6. [--start num]
  7. Initialize the counter at the number 'num' insetad of '0'.Most between '0'and'value'-1.
  8. [--packet num]
  9. Match on 'num' packet.Most be between '0'and'value'-1.
  10. 来源: http://linux.die.net/man/8/iptables
  1. BALANCE
  2. This allows you to DNAT connections in a round-robin way over a given range of destination addresses.
  3. --to-destination ipaddr-ipaddr
  4. Address range to round-robin over.

这里有两个做法不同的例子:
http://www.cnblogs.com/silenceli/p/3569849.html
http://wjw465150.iteye.com/blog/423704

防止DDOS攻击

参考此文:
http://sookk8.blog.51cto.com/455855/321242

日志功能

用户空间日志:

  1. ULOG
  2. This target provides userspace logging of matching packets.Whenthis target issetfor a rule, the Linux kernel will multicast this packet through a netlink socket.Oneor more userspace processes may then subscribe to various multicast groups and receive the packets.Like LOG,thisis a "non-terminating target", i.e. rule traversal continues at the next rule.

内核日志:

  1. LOG
  2. Turn on kernel logging of matching packets.Whenthis option issetfor a rule, the Linux kernel will print some information on all matching packets (like most IP header fields) via the kernel log (where it can be read with dmesg or syslogd(8)).Thisis a "non-terminating target", i.e. rule traversal continues at the next rule.Soif you want to LOG the packets you refuse,use two separate rules with the same matching criteria, first using target LOG then DROP (or REJECT).

参考资料:
http://linux.die.net/man/8/iptables

iptables能够做什么的更多相关文章

  1. 使用iptables做端口转发

    通过iptables可以做转发 #!/bin/sh IPT="/sbin/iptables" /bin/echo "1" > /proc/sys/net/ ...

  2. iptables rule

    和H3C中的acl很像,或者就是一会事,这就是不知道底层的缺陷,形式一变,所有的积累都浮云了 参考准确的说copy from http://www.ibm.com/developerworks/cn/ ...

  3. squid透明代理+iptables防火墙,多网卡详细配置

    squid透明代理+iptables防火墙详细配置 看到很多人都在不停地问iptables+squid做透明代理的问题,鄙人不才,斗胆在此做统一解答.如有任何纰漏还望各位批评指教. ========= ...

  4. iptables初探

    一,前言 本来想起个名字叫做"小白都是怎么学习iptables的?"或者"你为什么还不了解iptables?"等等,就像简书上的头条文章,虽然被说成" ...

  5. linux iptables规则介绍

    今天又学习了一下iptables,做一点总结来方便以后查阅. Netfilter(网络过滤器)是Linux操作系统核心层内部的一个数据包处理模块,主要负责数据包的拦截和转发,而iptables是Net ...

  6. 使用iptables基于MAC地址进行访控

    近日完成一台基于CentOS的SVN服务器配置,由于该服务器上的文件非常重要,仅部分用户需要访问,最后决定采用iptables来做访控,并且是根据MAC地址来限制,为了便于后期维护,防火墙的配置是通过 ...

  7. Iptables 指南 1.1.19

    Iptables 指南 1.1.19 Oskar Andreasson oan@frozentux.net Copyright © 2001-2003 by Oskar Andreasson 本文在符 ...

  8. 15、iptables详解

    --     http://www.netfilter.org/ http://www.iptables.org/     --参考路径 http://www.netfilter.org/docume ...

  9. iptables 及容器网络分析

    本文独立博客阅读地址:https://ryan4yin.space/posts/iptables-and-container-networks/ 本文仅针对 ipv4 网络 iptables 提供了包 ...

随机推荐

  1. jquery在线五子棋

    在线五子棋试玩地址:http://keleyi.com/game/12/ 以下是完整代码,保存到html文件打开也可以玩: <!DOCTYPE html> <html> < ...

  2. ASP.NET MVC 简介

    1. ASP.NET MVC 是什么? ASP.NET MVC是微软官方提供的以MVC模式为基础的ASP.NET Web应用程序(Web Application)框架,它由Castle的MonoRai ...

  3. angular源码分析:angular中$rootscope的实现——scope的一生

    在angular中,$scope是一个关键的服务,可以被注入到controller中,注入其他服务却只能是$rootscope.scope是一个概念,是一个类,而$rootscope和被注入到cont ...

  4. html meta标签使用总结

    meta标签作用 META标签是HTML标记HEAD区的一个关键标签,提供文档字符集.使用语言.作者等基本信息,以及对关键词和网页等级的设定等,最大的作用是能够做搜索引擎优化(SEO). PS:便于搜 ...

  5. 实现UITextView的placeholder

    我们知道在iOS开发时,控件UITextField有个placeholder属性,UITextField和UITextView使用方法基本类似,有两个小区别:1.UITextField单行输入,而UI ...

  6. Linux安全基础:find命令的使用

    find 命令用于查找文件系统中的指定文件. *命令格式:find pathname -option [-print -exex -ok] 1.pathname要查找的目录路径 ~表示home目录 . ...

  7. iOS之UIScrollView循环滚动

    #import "ViewController.h" #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width #d ...

  8. 在TableView上添加悬浮按钮

    如果直接在TableVIewController上贴Button的话会导致这个会随之滚动,下面解决在TableView上实现位置固定悬浮按钮的两种方法: 1.在view上贴tableView,然后将悬 ...

  9. SQL2008中的Sequence

        CREATE TABLE dbo.GlobalSequence ( id INT IDENTITY(1, 1) ) GO     CREATE PROC seq ( @id INT OUTPU ...

  10. TortoiseSVN与VisualSVN Server搭建SVN版本控制系统

    本片主要介绍如何搭建SVN版本控制系统,主要使用工具: 1 客户端:TortoiseSVN (小乌龟) 2 服务端:VisualSVN Server 搭建出图形化管理,以及右键菜单版本控制管理的SVN ...