Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to duplicate the traffic using IPTables? Is it possible?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
linck
n00b
n00b


Joined: 13 Mar 2005
Posts: 20
Location: Brasil

PostPosted: Sat Nov 11, 2006 7:02 pm    Post subject: How to duplicate the traffic using IPTables? Is it possible? Reply with quote

Hello.

I would like to know if there is a way to duplicate the traffic comming from one interface to another two network interface cards using IPTables. Is that possible?
For example: The traffic comming from eth0 should be duplicated and forwarded to eth1 and eth2, and the traffic comming from eth1 should be also duplicated and forwarded to eth2. I had been looking for iptables rules that could do that at google but I didn't find good results :cry:

Thank you.
Back to top
View user's profile Send private message
mark_lagace
Tux's lil' helper
Tux's lil' helper


Joined: 19 Nov 2002
Posts: 77
Location: Ottawa, Canada

PostPosted: Sun Nov 12, 2006 2:12 am    Post subject: Reply with quote

Is that something that would be done with iptables, or should you instead look into routing? I'm not sure what you mean by 'forwarded' I guess... For bridging one interface to another you could look into ebtables as well - I don't have enough experience with ebtables though to know if you can set up a one-to-many bridge.
Back to top
View user's profile Send private message
linck
n00b
n00b


Joined: 13 Mar 2005
Posts: 20
Location: Brasil

PostPosted: Sun Nov 12, 2006 2:40 am    Post subject: Reply with quote

mark_lagace wrote:
Is that something that would be done with iptables, or should you instead look into routing? I'm not sure what you mean by 'forwarded' I guess... For bridging one interface to another you could look into ebtables as well - I don't have enough experience with ebtables though to know if you can set up a one-to-many bridge.


Well, let me try to explain better, my English isn't very good :(

In the actual configuration, the traffic coming from eth1 is routed to eth0, and vice-versa.
What I want to do is to route the same traffic to one more network interface card.

Is there a way to do that? Using IPTables or something like that...

Thank you for your help.

*EDIT*
If IPTables can't do that, could it duplicate the traffic and forward it to another IP address?
Back to top
View user's profile Send private message
mark_lagace
Tux's lil' helper
Tux's lil' helper


Joined: 19 Nov 2002
Posts: 77
Location: Ottawa, Canada

PostPosted: Sun Nov 12, 2006 3:50 am    Post subject: Reply with quote

Look into ethernet bridging and see if that serves your needs. http://tldp.org/HOWTO/html_single/Ethernet-Bridge-netfilter-HOWTO/ is a good spot to start. What a bridge can do is link your three ethernet interfaces so that traffic from one interface will be passed along to the others. Basically it turns your linux-box into a glorified ethernet switch. If you want to still have remote access to your linux machine, don't forget to assign an ip to the bridge virtual interface.

Good luck!

EDIT: better documentation: http://linux-net.osdl.org/index.php/Bridge
Back to top
View user's profile Send private message
daeghrefn
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jan 2005
Posts: 112

PostPosted: Mon Nov 13, 2006 8:25 pm    Post subject: Reply with quote

I'm pretty sure you should be able to do this. It sounds to me like the same thing as putting two computers on a hub and using the second to monitor the traffic from the first.

I couldn't tell you exactly how, but I would assume that in the prerouting you would be able to copy all packets. I would also check the Netfilter configuration in the kernel... I don't have a box in front of me that I can do that, but I think I've seen stuff in there for auditing. I assume that's what this is for... network traffic logging/auditing.

HTH.
_________________
Support our troops.
Back to top
View user's profile Send private message
linck
n00b
n00b


Joined: 13 Mar 2005
Posts: 20
Location: Brasil

PostPosted: Mon Nov 13, 2006 9:08 pm    Post subject: Reply with quote

daeghrefn wrote:
I'm pretty sure you should be able to do this. It sounds to me like the same thing as putting two computers on a hub and using the second to monitor the traffic from the first.

I couldn't tell you exactly how, but I would assume that in the prerouting you would be able to copy all packets. I would also check the Netfilter configuration in the kernel... I don't have a box in front of me that I can do that, but I think I've seen stuff in there for auditing. I assume that's what this is for... network traffic logging/auditing.

HTH.


That is exactly what I want to do!!!
You are right about PREROUTING, but it will modify the destination IP of the packet instead of creating another one(a copy) and send it to the other destination, I think...

See you.
Back to top
View user's profile Send private message
mark_lagace
Tux's lil' helper
Tux's lil' helper


Joined: 19 Nov 2002
Posts: 77
Location: Ottawa, Canada

PostPosted: Sat Nov 18, 2006 12:27 am    Post subject: Reply with quote

Could you use something like this to take all packets coming in to 192.168.100.5 and forward them on to 192.168.120.1 through 192.168.120.5 (or however many you like)?
Code:

iptables -t nat -A PREROUTING -d 192.168.100.5 -j DNAT --to-destination 192.168.120.1-192.168.120.5


I'm not sure that this works and don't really have a good way to test it, but it might be worth a try.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum