前言

在这两篇博文中已经具体分析了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. JavaScript事件对象与事件处理程序

    在学习之前建议请看一下事件流.事件冒泡.事件捕获 一.事件对象 事件对象:在DOM触发事件时,会产生一个事件对象event,这个事件对象包含着所有与事件相关的信息.既然event是事件对象,那么它必然 ...

  2. jquery.datatable.js与CI整合 异步加载(大数据量处理)

    http://blog.csdn.net/kingsix7/article/details/38928685 1.CI 控制器添加方法 $this->show_fields_array=arra ...

  3. ArcGIS JS 学习笔记3 实现百度风格的BubblePopup

    1. 开篇 模仿是最好的学习,这次我们继续山寨百度,通过自定义Infowindow来实现百度风格的BubblePopup 2.准备 2.1 Copy模板 先打开百度地图,按下f12吧BubblePop ...

  4. Android高效计算——RenderScript(一)

    高效计算——RenderScript RenderScript是安卓平台上很受谷歌推荐的一个高效计算平台,它能够自动把计算任务分配到各个可用的计算核心上,包括CPU,GPU以及DSP等,提供十分高效的 ...

  5. iOS9请求https问题-记录

    iOS9 开始苹果将HTTP全改为HTTPS了,所以出现网络请求失败问题,解决办法: 1.改回HTTP: 在info.plist文件中添加一个Key:NSAppTransportSecurity(字典 ...

  6. RESTORE detected an error on page (0:0) in database

    在测试服务器还原生产服务器的一个数据库时遇到了下面错误: System.Data.SqlClient.SqlError: RESTORE detected an error on page (0:0) ...

  7. Linux监控工具介绍系列——smem

    smem工具介绍 smem是Linux系统上的一款可以生成多种内存耗用报告的命令行工具.与现有工具不一样的是smem可以报告实际使用的物理内存(PSS),这是一种更有意义的指标.可以衡量虚拟内存系统的 ...

  8. 【hive】——Hive初始了解

    1.没有接触,不知道这个事物是什么,所以不会产生任何问题.2.接触了,但是不知道他是什么,反正我每天都在用.3.有一定的了解,不够透彻.那么hive,1.我们对它了解多少?2.它到底是什么?3.hiv ...

  9. mongo学习笔记(一):增删改查

    安装:我是按这篇来弄的 一.Insert 1.db.person.insert({"name":"jack","age":20}) 2.va ...

  10. SQL Server 2008 R2——使用计算列为表创建自定义的自增列

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  请通过右侧公告中的“联系邮 ...