IP traffic between two NICs on same box

Discussion in 'Linux Networking' started by Harald Radke, Jul 29, 2012.

  1. Harald Radke

    Harald Radke Guest

    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
     
    Harald Radke, Jul 29, 2012
    #1
    1. Advertisements

  2. Harald Radke

    Tauno Voipio Guest


    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, Jul 29, 2012
    #2
    1. Advertisements

  3. Harald Radke

    looxrat Guest

    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.
     
    looxrat, Jul 29, 2012
    #3
  4. Harald Radke

    Qwest

    Joined:
    Jul 29, 2012
    Messages:
    1
    Likes Received:
    0
    Yup, came here to suggest VMWare!
     
    Qwest, Jul 29, 2012
    #4
  5. Harald Radke

    Moe Trin Guest

    On Sun, 29 Jul 2012, in the Usenet newsgroup comp.os.linux.networking, in
    article <>,
    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.
    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.
    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
     
    Moe Trin, Jul 30, 2012
    #5
  6. 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.
     
    Robert Nichols, Jul 30, 2012
    #6
  7. Harald Radke

    Rick Jones Guest

    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
     
    Rick Jones, Jul 30, 2012
    #7
  8. Harald Radke

    unruh Guest

     
    unruh, Jul 30, 2012
    #8
  9. Hello,

    Moe Trin a écrit :
    Other people have already done the job. See Julian Anastasov's
    Send-To-Self patch for example. <http://www.ssi.bg/~ja/#loop>
     
    Pascal Hambourg, Aug 4, 2012
    #9
  10. Robert Nichols a écrit :
    The box can even do it itself with iptables DNAT and SNAT rules and ARP
    static entries.
     
    Pascal Hambourg, Aug 4, 2012
    #10
  11. Harald Radke

    ein Guest

     
    ein, Aug 5, 2012
    #11
  12. ein a écrit :
    Thanks for digging this out. I vaguely remembered I posted it somewhere,
    but was too lazy to search where and when.
     
    Pascal Hambourg, Aug 5, 2012
    #12
  13. Harald Radke

    ein Guest

    Great post, I was copy it. :)
     
    ein, Aug 5, 2012
    #13
  14. Harald Radke

    ein Guest

    *I copied it.
     
    ein, Aug 5, 2012
    #14
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.