Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #1532 > unrolled thread

IP traffic between two NICs on same box

Started byHarald Radke <looxrat@googlemail.com>
First post2012-07-29 02:04 -0700
Last post2012-08-05 15:34 +0200
Articles 13 — 9 participants

Back to article view | Back to comp.os.linux.networking


Contents

  IP traffic between two NICs on same box Harald Radke <looxrat@googlemail.com> - 2012-07-29 02:04 -0700
    Re: IP traffic between two NICs on same box Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2012-07-29 22:56 +0300
      Re: IP traffic between two NICs on same box looxrat@googlemail.com - 2012-07-29 13:32 -0700
        Re: IP traffic between two NICs on same box Moe Trin <ibuprofin@painkiller.example.tld.invalid> - 2012-07-29 20:43 -0500
          Re: IP traffic between two NICs on same box Robert Nichols <SEE_SIGNATURE@localhost.localdomain.invalid> - 2012-07-30 08:15 -0500
            Re: IP traffic between two NICs on same box Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> - 2012-08-04 12:52 +0200
          Re: IP traffic between two NICs on same box Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> - 2012-08-04 12:49 +0200
    Re: IP traffic between two NICs on same box Rick Jones <rick.jones2@hp.com> - 2012-07-30 17:46 +0000
    Re: IP traffic between two NICs on same box unruh <unruh@invalid.ca> - 2012-07-30 17:57 +0000
    Re: IP traffic between two NICs on same box ein <ein@no.spam> - 2012-08-05 14:26 +0200
      Re: IP traffic between two NICs on same box Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> - 2012-08-05 14:59 +0200
        Re: IP traffic between two NICs on same box ein <ein@no.spam> - 2012-08-05 15:32 +0200
          Re: IP traffic between two NICs on same box ein <ein@no.spam> - 2012-08-05 15:34 +0200

#1532 — IP traffic between two NICs on same box

FromHarald Radke <looxrat@googlemail.com>
Date2012-07-29 02:04 -0700
SubjectIP traffic between two NICs on same box
Message-ID<9ad2e5d7-847c-47b9-8518-095c479d1141@googlegroups.com>
Hi there!

I have a Linux box with several NICs. What I want is the following setup:

* eth1 - 192.168.100.1
* eth2 - 192.168.100.2
* a physical network connection between both interfaces.


Now I am looking for a way, to enforce IP traffic from 192.168.100.1 to 192.168.100.2 and back to use the network link and not being routed internally.

I have no problem with more esotheric solutions, if all fails, I guess I will code my way through the kernel, but of course I would prefer any less drastic solution.

Thx and regards

Harry

[toc] | [next] | [standalone]


#1533

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2012-07-29 22:56 +0300
Message-ID<jv44ha$dpq$1@dont-email.me>
In reply to#1532
On 29.7.12 12:04 , Harald Radke wrote:
> Hi there!
>
> I have a Linux box with several NICs. What I want is the following setup:
>
> * eth1 - 192.168.100.1
> * eth2 - 192.168.100.2
> * a physical network connection between both interfaces.
>
>
> Now I am looking for a way, to enforce IP traffic from 192.168.100.1 to 192.168.100.2 and back to use the network link and not being routed internally.
>
> I have no problem with more esotheric solutions, if all fails, I guess I will code my way through the kernel, but of course I would prefer any less drastic solution.
>
> Thx and regards
>
> Harry


This should be in a FAQ:

The kernel IP stack is smart enough to route traffic from a host
to *ANY* of its own interfaces via the loopback device lo.

Would you please tell why?

For testing a network with only one piece of hardware available,
a virtual machine setup might help (e.g. VirtualBox or VMWare).

-- 

Tauno Voipio

[toc] | [prev] | [next] | [standalone]


#1534

Fromlooxrat@googlemail.com
Date2012-07-29 13:32 -0700
Message-ID<13f5c0f9-f0fc-497c-8770-b89b57963050@googlegroups.com>
In reply to#1533
Well, I know that the kernel does that, I am looking for a way to bypass that...

Indeed this is gonna be a testing device and preferably I would get around virtualization, I have never worked with that before,  I imagine that this will be quite some work, and I wonder about performance issues.

[toc] | [prev] | [next] | [standalone]


#1535

FromMoe Trin <ibuprofin@painkiller.example.tld.invalid>
Date2012-07-29 20:43 -0500
Message-ID<slrnk1bplf.sn4.ibuprofin@fermi.phx.az.us>
In reply to#1534
On Sun, 29 Jul 2012, in the Usenet newsgroup comp.os.linux.networking, in
article <13f5c0f9-f0fc-497c-8770-b89b57963050@googlegroups.com>,
looxrat@googlemail.com wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen.  Find a real news server.

<quoting fixed>

]Tauno Voipio wrote:

]] The kernel IP stack is smart enough to route traffic from a host
]]to *ANY* of its own interfaces via the loopback device lo.

>Well, I know that the kernel does that, I am looking for a way to
>bypass that...

You'll have to re-write the stack - no simple matter.

]] For testing a network with only one piece of hardware available,
]] a virtual machine setup might help (e.g. VirtualBox or VMWare).

It may actually be less of a hassle to just find a second real box.

>Indeed this is gonna be a testing device and preferably I would get
>around virtualization, I have never worked with that before,  I
>imagine that this will be quite some work, and I wonder about
>performance issues.

Recently discussed in another group - performance hit is about 20%
in addition to dividing the resources.    Really - grab another
system, and save yourself the trouble.

        Old guy

[toc] | [prev] | [next] | [standalone]


#1536

FromRobert Nichols <SEE_SIGNATURE@localhost.localdomain.invalid>
Date2012-07-30 08:15 -0500
Message-ID<jv61ed$32j$1@omega-3a.local>
In reply to#1535
On 07/29/2012 08:43 PM, Moe Trin wrote:
> On Sun, 29 Jul 2012, in the Usenet newsgroup comp.os.linux.networking, in
> article<13f5c0f9-f0fc-497c-8770-b89b57963050@googlegroups.com>,
> looxrat@googlemail.com wrote:
> ]] For testing a network with only one piece of hardware available,
> ]] a virtual machine setup might help (e.g. VirtualBox or VMWare).
>
> It may actually be less of a hassle to just find a second real box.

Or, just stick a NAT router between the two ports and configure its
forwarding so that your box doesn't realize it's talking to itself.

-- 
Bob Nichols         AT comcast.net I am "RNichols42"

[toc] | [prev] | [next] | [standalone]


#1559

FromPascal Hambourg <boite-a-spam@plouf.fr.eu.org>
Date2012-08-04 12:52 +0200
Message-ID<jviutb$2ki1$1@saria.nerim.net>
In reply to#1536
Robert Nichols a écrit :
> On 07/29/2012 08:43 PM, Moe Trin wrote:
>> looxrat@googlemail.com wrote:
>> ]] For testing a network with only one piece of hardware available,
>> ]] a virtual machine setup might help (e.g. VirtualBox or VMWare).
>>
>> It may actually be less of a hassle to just find a second real box.
> 
> Or, just stick a NAT router between the two ports and configure its
> forwarding so that your box doesn't realize it's talking to itself.

The box can even do it itself with iptables DNAT and SNAT rules and ARP
static entries.

[toc] | [prev] | [next] | [standalone]


#1558

FromPascal Hambourg <boite-a-spam@plouf.fr.eu.org>
Date2012-08-04 12:49 +0200
Message-ID<jviuno$2kbe$1@saria.nerim.net>
In reply to#1535
Hello,

Moe Trin a écrit :
> looxrat@googlemail.com wrote:
> 
> ]Tauno Voipio wrote:
> 
> ]] The kernel IP stack is smart enough to route traffic from a host
> ]]to *ANY* of its own interfaces via the loopback device lo.
> 
>> Well, I know that the kernel does that, I am looking for a way to
>> bypass that...
> 
> You'll have to re-write the stack - no simple matter.

Other people have already done the job. See Julian Anastasov's
Send-To-Self patch for example. <http://www.ssi.bg/~ja/#loop>

[toc] | [prev] | [next] | [standalone]


#1537

FromRick Jones <rick.jones2@hp.com>
Date2012-07-30 17:46 +0000
Message-ID<jv6h9a$5lt$1@usenet01.boi.hp.com>
In reply to#1532
Years ago Ben Grear (I think it was Ben Grear) posted some patches to
the netdev list that would allow IP between two local IPs to go out
one NIC and in another, but it was not accepted because the use case
is too rare.  I would second/third/whatnot the suggestions to get a
second system.

Now, if you are willing to content yourself with just layer-two
traffic (eg Ethernet) and not IP, you could use AF_PACKET sockets and
send traffic out the one port and in the other.  But that won't be IP.

rick jones
-- 
denial, anger, bargaining, depression, acceptance, rebirth...
                                     where do you want to be today?
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to rick.jones2 in hp.com  but NOT BOTH...

[toc] | [prev] | [next] | [standalone]


#1538

Fromunruh <unruh@invalid.ca>
Date2012-07-30 17:57 +0000
Message-ID<NVzRr.5414$BI5.5205@newsfe09.iad>
In reply to#1532
On 2012-07-29, Harald Radke <looxrat@googlemail.com> wrote:
> Hi there!
>
> I have a Linux box with several NICs. What I want is the following setup:
>
> * eth1 - 192.168.100.1
> * eth2 - 192.168.100.2
> * a physical network connection between both interfaces.
>
>
> Now I am looking for a way, to enforce IP traffic from 192.168.100.1 to 192.168.100.2 and back to use the network link and not being routed internally.

Why? 

>
> I have no problem with more esotheric solutions, if all fails, I guess I will code my way through the kernel, but of course I would prefer any less drastic solution.
>

[toc] | [prev] | [next] | [standalone]


#1560

Fromein <ein@no.spam>
Date2012-08-05 14:26 +0200
Message-ID<jvloov$m3h$1@node1.news.atman.pl>
In reply to#1532
Pascal Hambourg wrote:
 > Hello,
 >
 > Giro a écrit :
 >> >
 >> >  Is there any way to let two local network interfaces communicate with
 >> >  each other without using the loopback device?
 > Not easily.
 > First, the kernel forces packets with a local destination address
 > through the loopback interface. Second, the kernel discards packets
 > received on a non-loopback interface with a local source address.
 >
 >> >  On the same computer, I have interfaces eth1 (192.168.0.11) and eth2
 >> >  (192.168.0.12).  I want to
 >> >  ping from eth1 to eth2, and make the packet physically hit the wire,
 >> >  instead of going through the loopback device.
 > The above restrictions can be worked around with iptables NAT rules and
 > static ARP entries, tricking the kernel into believing that it is
 > communicating with a remote host. Sensitive people beware : what follows
 > is ugly.
 >
 > Say that "remote" eth1 will be seen as 192.168.0.21 and "remote" eth2 as
 > 192.168.0.22.
 >
 > # make sure packets to "remote" addresses are routed through the correct
 > # interface
 > ip route add 192.168.0.21 dev eth2
 > ip route add 192.168.0.22 dev eth1
 >
 > # create static ARP entries for the remote addresses
 > arp -s 192.168.0.21 $eth1_mac_address
 > arp -s 192.168.0.22 $eth2_mac_address
 >
 > # replace the source address of outgoing packets with the "remote"
 > # addresses
 > iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 192.168.0.21
 > iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to 192.168.0.22
 >
 > # replace the destination address of incoming packets with the real
 > # local addresses
 > iptables -t nat -A PREROUTING -i eth1 -j DNAT --to 192.168.0.11
 > iptables -t nat -A PREROUTING -i eth2 -j DNAT --to 192.168.0.12
 >
 > With this a packet sent to 192.168.0.21 or 192.168.0.22 and its reply
 > should go on the wire.


-- 
PGP Public Key:
ID: 0x3AEA3541
MD5: 608E 6B7B 7CA9 6F52 D3DF 6351 6E14 FF30 3AEA 3541

[toc] | [prev] | [next] | [standalone]


#1561

FromPascal Hambourg <boite-a-spam@plouf.fr.eu.org>
Date2012-08-05 14:59 +0200
Message-ID<jvlqn4$i55$1@saria.nerim.net>
In reply to#1560
ein a écrit :
> Pascal Hambourg wrote:
>  > The above restrictions can be worked around with iptables NAT rules and
>  > static ARP entries, tricking the kernel into believing that it is
>  > communicating with a remote host. [...]

Thanks for digging this out. I vaguely remembered I posted it somewhere,
but was too lazy to search where and when.

[toc] | [prev] | [next] | [standalone]


#1562

Fromein <ein@no.spam>
Date2012-08-05 15:32 +0200
Message-ID<jvlslk$pou$1@node1.news.atman.pl>
In reply to#1561
Pascal Hambourg wrote:
> ein a écrit :
>> Pascal Hambourg wrote:
>>   >  The above restrictions can be worked around with iptables NAT rules and
>>   >  static ARP entries, tricking the kernel into believing that it is
>>   >  communicating with a remote host. [...]
>
> Thanks for digging this out. I vaguely remembered I posted it somewhere,
> but was too lazy to search where and when.

Great post, I was copy it. :)

[toc] | [prev] | [next] | [standalone]


#1563

Fromein <ein@no.spam>
Date2012-08-05 15:34 +0200
Message-ID<jvlsou$pou$2@node1.news.atman.pl>
In reply to#1562
ein wrote:
> Pascal Hambourg wrote:
>> ein a écrit :
>>> Pascal Hambourg wrote:
>>>    >   The above restrictions can be worked around with iptables NAT rules and
>>>    >   static ARP entries, tricking the kernel into believing that it is
>>>    >   communicating with a remote host. [...]
>>
>> Thanks for digging this out. I vaguely remembered I posted it somewhere,
>> but was too lazy to search where and when.
>
> Great post, I was copy it. :)
*I copied it.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.networking


csiph-web