前言

在这两篇博文中已经具体分析了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. SharePoint 2013 入门教程之创建及修改母版页

    在SharePoint 2013中,微软提供了根据HTML页面转换Master页的方法,并支持单项同步,但是这样的更新,并不完善,会使一些功能造成丢失,所以,了解Master结构的人,尽量直接去修改M ...

  2. SharePoint 2013 搜索功能,列表项目不能完全被索引

    描述 最近一个站点,需要开启搜索功能,然后创建内容源,开始爬网,发现列表里只有一部分被索引,很多项目没有被索引,甚是奇怪,如下图(其实列表里有80几条项目). 首先爬网账号是系统账号.服务器管理员,所 ...

  3. IOS开发基础知识--碎片41

    1:UIWebView加载本地的HTML NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fi ...

  4. 【iOS】Alamofire库在iOS7下设置Head无效的问题

    声明  欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯伯: http://over140.cnblogs.com 正文 同样的代码在iOS8下没有问 ...

  5. 【原】设置iOS项目BuildVersion自动增加

    一.概念阐述:Build与Version的区别 在iOS中有两种“版本号”,也就是所谓的version号与build号,如下图所示: 我们用最简洁的语言来区分这两个版本号的区别以及用途如下: Vers ...

  6. Python语言Web开发框架web2py

    python开发的强大的网络框架web2py,这个框架需要下载和集成. http://www.web2py.com/examples/static/web2py_src.zip

  7. 忘记Mysql的root密码怎么办?

    有时候忘掉了mysql的root密码,这种情况下,如何重置root的密码呢? 找到并编辑mysql的my.ini配置文件,在mysqld节点中添加上skip-grant-table. 如下: [mys ...

  8. 第一次写博客Poj1044

    Date bugs Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3005   Accepted: 889 Descript ...

  9. MYSQL介绍安装及一些问题解决

    一.简介 MySQL是最流行的开放源码SQL数据库管理系统,它是由MySQL AB公司开发.发布并支持的.有以下特点: MySQL是一种数据库管理系统. MySQL是一种关联数据库管理系统. MySQ ...

  10. Python学习笔记2-解析数据

    Import os; -- Python自带 print(os.getcwd()) -- 获得当前工作目录 os.chdir('/Users/longlong/Documents') -- 转换到/U ...