Changes between Initial Version and Version 1 of Internal/netfilter


Ignore:
Timestamp:
Apr 16, 2006, 3:15:32 AM (19 years ago)
Author:
ergin
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/netfilter

    v1 v1  
     1= Netfilter/iptables for ORBIT =
     2
     3This document briefly describes netfilter framework, and lists some of its
     4capabilities. Motivation is to see how regular users of ORBIT can make use of
     5it (if they will ever need it).
     6
     7
     8== Overview ==
     9
     10[http://www.netfilter.org/ Netfilter] is a packet filtering framework that appeared with Linux kernel version 2.4.
     11It has a complete re-design and netfilter framework can be thought as a successor of ipchains/ipfwadm
     12that were used with 2.0/2.2 kernels.
     13
     14In many contexts, netfilter and iptables are used interchangeably. The correct way to perceive this is
     15explained as follows. Netfilter is the name given to the overall framework of this packet filtering oriented
     16project. Under this project, there are four main components
     17
     18 * '''netfilter'''
     19This is at the heart of the framework (so, gives its name to the overall framework) and it provides a means for
     20any given kernel module (not necessarily  part of netfilter framework) to deal with network packets by letting them
     21register callback functions with the network stack.
     22
     23 * '''ip_tables'''
     24Provides a generic table structure for rulesets and these rules are matched with packets to map them to
     25specific actions. Similar to other components, it uses netfilter for this purpose. Also, (confusingly enough)
     26the name of the userspace program that allows managing the rulesets of ip_tables is called iptables.
     27
     28 * '''connection tracking'''
     29Connection tracking is an integral part of NAT, but it is implemented as a separate module to allow for
     30extensions. It is the `state' module of the framework.
     31
     32 * '''NAT subsystem'''
     33As the name implies, it realizes the NAT process except connection tracking part. NAT, in netfilter terms, should be
     34considered as two different types: Source NAT (SNAT) and Destination NAT (DNAT).
     35
     36Source NAT is when you alter the source address of the first packet: i.e. you are changing where the connection is coming from.
     37Source NAT is always done post-routing, just before the packet goes out onto the medium. Masquerading is a specialized form of SNAT.
     38
     39Destination NAT is when you alter the destination address of the first packet: i.e. you are changing where the connection is going to.
     40Destination NAT is always done before routing, when the packet first comes off the wire. Port forwarding, load sharing, and transparent
     41proxying are all forms of DNAT.
     42
     43Currently, netfilter provides the following hooks to be excited:
     44
     45[[Image(netfilter1.png)]]
     46                 
     47
     48The arrows indicate the travel direction of packet as it visits each netfilter hook.
     49
     50
     51== Possible Usage Scenarios ==
     52
     53
     54 * '''Easy Packet Filtering'''
     55
     56User's experiment is using any standard available routing protocol for Linux (AODV, DSR, Lunar etc.) and
     57he/she is not modifying/maintaining this routing protocols source code. So, by employing iptables, he/she
     58can do stateless or stateful packet filtering (IPv4 or IPv6) based on
     59
     60  * host names, IP addresses, MAC addresses, or physical/logical interface itself
     61  * TCP, UDP, or ICMP protocols
     62  * TCP flags through TCP extensions
     63  * Packet lengths
     64  * Packet type (host/broadcast/multicast)
     65  * TTL / ToS / More Fragments etc.
     66  * IP states through connection tracking
     67
     68In addition to acting on the above stated conditions, user might use iptables only to
     69log those cases, without doing anything.
     70
     71
     72 * '''Random Packet Drop'''
     73User might use iptables easily to deploy a random packet drop probability between
     74.1<=p<=.99 This way, a packet level link quality enforcement (including wired side)
     75can be implemented
     76       
     77 * '''String Search in Packets'''
     78User can specify strings to be matched and processed through iptables. This is
     79rather useful for debugging purposes, not content based routing/filtering (it will
     80be real slow otherwise). An example would be checking a custom routing protocols update
     81message to see if a specific destination IP is included in payload.
     82
     83 * '''IP Header modifications'''
     84User can do some basic IP header field manipulations (mangling) like altering the
     85TOS/DSCP/ECN bits of the IP header, without dealing with reading packet to userspace
     86or modifying kernel source.
     87
     88 * '''Rough Packet Timing'''
     89Users may filter or log packets that belong to a time window based on their time
     90of arrival. However, this would have a granularity of at most one minute. Might
     91be used for analyzing a snapshot of packets during a long experiment.
     92
     93 * '''Forwarding and NAT'''
     94By making use of the above matching opportunities, users may define rules to bypass
     95the existing routing mechanism on the node and forward/rewrite packets regardless
     96of nodes normal action plan (by exciting prerouting chain). This can be used to enforce fixed
     97routes, or pseduo multi-hops (through MAC address based drops).
     98
     99Also, if the experiment requires, user can implement a transparent proxy on a
     100node to check the performance of the scheme under investigation with such a
     101proxy in network.
     102
     103 * '''More scenarios TBA'''