Kernel Korner - The Hidden Treasures of iptables
The random match module matches packets based on nothing more than a random choice. You can tune the logic by setting the probability that a packet is matched anywhere between 0% and 100% of the time. Example applications include simulating a faulty connection or server or distributing load across multiple mirrored Web servers. The example below distributes Web traffic among three servers. The first rule sends 33% of the connections to the server at 192.168.0.100. The next 33% is sent to 192.168.0.101 and the last third catches the remainder and passes them to 192.168.0.102:
iptables -t nat -A PREROUTING -i eth0 -p tcp \ --dport 80 --syn -m random --average 33 \ -j DNAT --to-destination 192.168.0.100:80 iptables -t nat -A PREROUTING -i eth0 -p tcp \ --dport 80 --syn -m random --average 50 \ -j DNAT --to-destination 192.168.0.101:80 iptables -t nat -A PREROUTING -i eth0 -p tcp \ --dport 80 --syn -j DNAT \ --to-destination 192.168.0.102:80
Dozens of treasures can be dug up and enjoyed. I have described a small handful here, but there are plenty more. Simply running the runme script and reading the patch descriptions as they are displayed is one way of getting an idea of what is available. Here are a few more examples of what you can find:
Connection tracking for RSH, MMS (media streaming), PPTP, Quake, RPC and Talk.
Extended support for configuration and status information access through the /proc filesystem.
Extended support for IPv6 features.
Manipulation of options, TTL and more in IP packets.
Finer control over NATed connections.
Control over limits on quota and bandwidth usage.
Anti-OS fingerprinting logic and port-scan detection.
Connection marking (and mark testing).
The patches added with POM don't add their descriptions to the iptables man page, so we need to turn elsewhere for documentation. The basic syntax used to invoke these extensions can be displayed using the iptables built-in help facility. For example, iptables -m random -help gives the usual help message but with the random module's parameters displayed at the end. The same technique can be applied to the other modules.
You also can refer to the module help files held in the Patch-o-matic directory structure. The file for random is base/random.patch.help. Similar files can be found for the other patches.
Finally, make use of the Netfilter Web site, www.netfilter.org/patch-o-matic, which contains a description of each of the POM patches.
The majority of iptables extensions have two parts, a patch to the Linux kernel and a configuration helper library for use by the iptables user-space program. The detailed procedure for adding a POM module to the kernel and the iptables tools is outlined at www.lowth.com/howto/add-iptables-modules.php. In summary, the steps we need to take are bring your system up to date; download the latest Patch-o-matic sources; patch the kernel using the runme script; recompile and install the patched kernel; and recompile and install the iptables software.
We have seen that Linux's Netfilter provides an excellent set of features for building effective firewalls, but not all of these features are installed by default on many Linux distributions. The Patch-o-matic software allows administrators to extend the base functionalities of their firewalls through an automated approach to patching the Linux kernel.
To finish, take this thought with you: we have seen that iptables/Netfilter has a number of exciting possibilities hidden away from initial inspection. The chances are high that the same is true for other packages. This is part of the joy of open-source software; nothing is truly hidden. Everything that exists is waiting there for the skilled seeker to find.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Kernel Problem
9 hours 13 min ago - BASH script to log IPs on public web server
13 hours 40 min ago - DynDNS
17 hours 16 min ago - Reply to comment | Linux Journal
17 hours 48 min ago - All the articles you talked
20 hours 12 min ago - All the articles you talked
20 hours 15 min ago - All the articles you talked
20 hours 17 min ago - myip
1 day 41 min ago - Keeping track of IP address
1 day 2 hours ago - Roll your own dynamic dns
1 day 7 hours ago





Comments
awsome
great information, thanks alot.
Xtables-addons is the successor to patch-o-matic(-ng)
Xtables-addons is the successor to patch-o-matic(-ng). Likewise, it contains extensions that were not accepted in the main iptables package.
Xtables-addons is different from patch-o-matic in that you do not have to patch or recompile either kernel or Xtables(iptables).
http://jengelh.medozas.de/projects/xtables/
Thanks
Wonderful ! thank you for this great post ! it really shows the power of iptables ! and this is juste a sample :)