LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-03-2009, 02:30 PM   #1
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
pass traffic externally across two local interfaces?


I have a box with two interfaces. I want to send traffic out one network interface, on to the network, and have the traffic's destination be the other interface.

Example (this doesnt work how I want it to, but is essentially what I want to achieve):
ifconfig eth0 192.168.1.1/24
ifconfig eth1 192.168.1.2/24
route add -host 192.168.1.1/32 dev eth1
route add -host 192.168.1.2/32 dev eth0

From the machine ping 192.168.1.1
Sniff the network, see ICMP traffic leaving eth1 with a destination of 192.168.1.1, see ICMP replies leaving eth0 with a destination of 192.168.1.2

How can I go about doing this?
 
Old 09-03-2009, 03:33 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,228

Rep: Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539
mebbe put a server using eth1, set eth0 as default route? A crossover cable might be helpful.
Things do this all the time with 127.0.0.1. I take it you are up to throughput tests, or something really weird.
We do collect nutty stories, you know ;-)
 
Old 09-03-2009, 03:49 PM   #3
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
Why would you do this? The only reason I can think of is that you want to test your routers. The easy way is just to run virtualbox and assign the second nic to a virtual host.
 
Old 09-03-2009, 04:05 PM   #4
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
Business kid:
Thanks for the response. Yes, I am going to be doing some throughput testing across different devices. As these devices are switches, a cross over cable wont help much. As for the suggested routing, I don't see that will be any better solution than what I suggested for routing in my original example.

Granted I am not a kernel expert, but I believe that what is happening is the kernel is taking a short cut. My guess is that the kernel looks at the IP destination and recognizes it to be a local interface. Then the kernel just gives the packet to that interface, instead of looking at the routing table. If this is truly the case, I need to stop the kernel from doing this pre-emptive routing.

I am currently looking at iptables, hoping that my solution can be found there.

any comments or observations are welcome.
 
Old 09-03-2009, 04:15 PM   #5
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
baldy:


In the past, virtualization is how I solved this problem; 1 host machine with 2 interfaces, 2 vm instances, each vm instance has 1 of the 2 interfaces.

This time I will have A LOT of interfaces and an box that probably cant handle 2 (or more) vm instances.

This box will be a tool, for pushing bandwidth across wireless and wired devices.
 
Old 09-04-2009, 04:12 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,228

Rep: Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539
My concern would be that the more hacking you do, the further away from a normal situation you get.
Why not use a second box?
 
Old 09-04-2009, 10:50 AM   #7
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
Ya I'm leaning towards that solution as well.
 
Old 09-05-2009, 04:02 AM   #8
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,228

Rep: Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539Reputation: 2539
It occurs to me as worth trying to remove the 'lo' interface allowing networking to 127.0.0.1 and have one last shot at doing it on a single box.
 
Old 09-05-2009, 05:56 AM   #9
nkhambal
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Rep: Reputation: 1
Not sure if it is possible, but you can also try this.

[Host-A IP]<--- NET-A--->[RTR]<--- NET-B --->[Host-B IP]

Here Host A and Host B are IPs on 2 NICs.

Here instead of sending traffic from Host-A to Host-B, send the traffic from Host-A to NET-B (may be just a single /32 host in NET-B) and from Host-B to NET-A.

On the router in the middle (or DUT), route the traffic for NET-A towards Host-A and for NET-B towards Host-B.

On Host-A, do a destination NAT for NET-A IP to Host-A IP.

On Host-B, do a destination NAT for NET-B IP to Host-B IP.

On Host-A, do a source NAT for Host-A IP to NET-A IP

On Host-B, do a source NAT for Host-B IP to NET-B IP

You should be able to do this with simple routes and NATs using IPTABLES.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Multiple interfaces - All traffic flows through just one... crazyivan Linux - Networking 16 03-05-2012 06:02 AM
Need help with routing some traffic throw different device/interfaces THOR_Fedora Linux - Networking 8 07-27-2009 10:18 AM
natting traffic between 2 interfaces nukenstien Linux - Networking 2 02-14-2005 12:12 AM
Traffic on both interfaces geomonap Linux - Networking 1 01-13-2005 03:56 PM
Traffic still going pass Firewall extremebfn Linux - Networking 1 10-04-2004 02:43 AM

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

All times are GMT -5. The time now is 11:41 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