LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2008, 03:44 PM   #1
jbarbieri
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Rep: Reputation: 0
iptables modules random and nth


Howdy,

Back in the linux 2.4 days with iptables, I was able to use a module called random, which would basically randomize outbound connections.

It was used mostly in the mangle table.


Now, I am trying to recompile a new kernel (2.6.24) and new iptables, but for the life of me, I can not find how to get the random module back. I have read some posts saying to use patch-o-matic....but patch-o-matic does not work. When I do make menuconfig, I don't see random anywhere under the netfilter modules.



This is what it looks like when it works:

Code:
43884 5105K ETH1       0    --  br0    *       0.0.0.0/0            0.0.0.0/0            random 50%
43752 5081K ETH2       0    --  br0    *       0.0.0.0/0            0.0.0.0/0            random 50%

Now, when I try and load the module, I get this:


Code:
[root@gateway scripts]# iptables -t mangle -A OUTPUT -o ! eth1 -m random --average 50 -j ETH1
iptables v1.3.8: Couldn't load match `random':/usr/local/lib/iptables/libipt_random.so: cannot open shared object file: No such file or directory

Try `iptables -h' or 'iptables --help' for more information.
[root@gateway scripts]#

I would like to use random because I have a dual-wan setup, and I need iptables to randomly choose which interface to go out of.


If you need any other info, let me know!

Thanks!
John
 
Old 04-18-2008, 10:03 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
One suggestion I have, is rather than use 'menuconfig' use xconfig instead (I hope you can run X) and from xconfig, use the EDIT--> SEARCH function from the menu, and search for 'random' and you will see any/all locations of the word 'random' within the kernel build.

FWIW, I have the full IPtables stuff all set up on my machine (all modules, 2.6.24.4), and I cannot locate a *random*.so anywhere.

Maybe what you might want to look into is the Linux Kernel BONDING driver, which can bond 2 ethernet NICs in various modes, like auto-fallback, load-balance, round-robin, etc.. It may or may not help resolve your exact desires/situation, but IS a way of selecting 1 of 2 or more WANs (NICs) to use at a given time.. you could maybe have them called eth0:0 and eth0:1 and just use some sort of arbitrary method (or the round-robin mode) to randomly choose between the 2.... ??

Hope this helps even a tiny bit


Sasha

Last edited by GrapefruiTgirl; 04-18-2008 at 10:14 AM.
 
Old 04-25-2008, 04:04 PM   #3
jbarbieri
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Except, I don't think with the bonding module you can do that with cable modems.....or can you?? And does it work with DHCP??
 
Old 04-25-2008, 07:43 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
I wouldn't see why not re: post#3 --

Cable Modem is an Ethernet connection (connects to the ether net port) and also as such, I don't see why DHCP wouldn't work.

You will need to look into the bonding documentation (usually included with your DOCS with your distro) or on Google. It should be easy to find. I haven't messed with it in a while, so I can't answer with specifics. But the text docs are pretty decent.

Sasha
 
Old 04-26-2008, 02:11 AM   #5
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
You can use iproute2 to do that. http://lartc.org/howto/lartc.rpdb.multiple-links.html
 
Old 04-28-2008, 07:40 AM   #6
jbarbieri
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by datopdog View Post

I am using that, but, I found you need to do some iptables rules with it too, if you use iptables, which I do.

Plus, random is better because even though the routes are cached in ip route, random will override the gateway, and send it out whichever interface is next.....so if you break a download up into 10 parts, 5 parts will be over one link, 5 parts will be over the second link.
 
Old 04-28-2008, 09:12 AM   #7
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
There is a kernel patch to fix the route caching problem take a look at it http://www.ssi.bg/~ja/#multigw
 
Old 07-09-2008, 08:39 AM   #8
luquee
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Rep: Reputation: 0
iptables statistics

in new kernels the implementations of nth an random is in modules statistics an it's part of iptables
 
Old 07-17-2008, 02:25 PM   #9
jbarbieri
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by luquee View Post
in new kernels the implementations of nth an random is in modules statistics an it's part of iptables


Is there any documentation for this?
 
Old 07-18-2008, 09:47 AM   #10
luquee
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Rep: Reputation: 0
doc iptables

the ip tables is

iptables -t nat -m statistic --mode nth --help

and

man iptables
 
Old 09-20-2009, 02:25 PM   #11
nima0102
Member
 
Registered: Nov 2006
Posts: 209

Rep: Reputation: 30
Hi
Thanks for you information
Does implementing these solutions (BONDING driver,iptables's nth module,iproute2 and etc ) for load balancing create some issue for connection? because using these solutions cause source IP of connections and sessions changed and may connection or session is lost.
thanks for any help or guidance
 
Old 09-21-2009, 06:33 AM   #12
luquee
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Rep: Reputation: 0
iptables

You see the piranha is the REAL lvs

http://www.centos.org/docs/5/html/Vi...ranha-VSA.html

Bye
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nth line of a file in perl kadhan Programming 1 02-20-2008 11:15 AM
iptables...prescedence, and random ports Basslord1124 Linux - Security 3 06-26-2007 12:29 PM
Insert after every nth character using sed DoDo1975 Linux - Software 2 01-17-2007 06:59 PM
find a Nth line in text file mahabooba Programming 2 07-24-2006 11:56 PM
n00b to the Nth degree flarpo LinuxQuestions.org Member Intro 3 08-17-2005 05:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration