Switchless TCP/IP networking?

Discussion in 'Linux Networking' started by Matthew Clark, Mar 10, 2006.

  1. If I had 4 linux boxes, A thru D each with two ethernet adapters 1 & 2
    and I chained them together via crossover cables where:

    A2 -> B1
    B2 -> C1
    C2 -> D1
    D2 -> A1

    / \
    D B
    \ /

    Could I set up TCP/IP networking/routing such that any box can reach
    any other? (Ie, Box A could telnet into Box C) If so, how do I?


    Matthew Clark, Mar 10, 2006
    1. Advertisements

  2. Matthew Clark

    Eric Teuber Guest

    Basically it is possible if you define all necessary routing rules. Also
    all boxes must be able to forward traffic from one ethernet adapter (1)
    to the other (2) and vice versa.

    The routing can be setup very easy by defining routes to each connected
    system (see man route). I.E. A must have a route to D and B, B to A and
    C and so on.

    Do you plan to have an outside connection to the internet on one of
    these systems? Then you should also define default gateways on each
    system. The internet box needs the router as default gateway. I.E. A is
    the internet box, the default gateways can be defined as follows:

    B -> C -> D -> A -> Internet

    The forwarding could be achieved by using iptables. Iptables (Netfilter)
    lets you forward traffic from one device to another (POSTROUTING and
    FORWARD). You will find a nice doc at

    I am sure, there are other solutions to forward traffic.

    May i ask you why you are thinking of such a network structure?

    Please don't hesitate to ask for more.

    Eric Teuber, Mar 10, 2006
    1. Advertisements

  3. As far as I know, this requires that all the "wires" be separate networks.
    The requirement is that the A interface pointing to B be on a separate
    network from all other interfaces except for the B interface pointing to A.
    This permits Linux's layer 3 routing to Do The Right Thing.

    I'd use /30 networks for each of those "point to point" links.

    I don't know of any way to do this at the ethernet frame level (ie. as a
    switch would). But I'm curious: is there a way for Linux to behave like a
    switch instead of (or in addition to) behaving like a router?

    - Andrew
    Andrew Gideon, Mar 10, 2006
  4. Hi, Eric. Thanks for responding.
    No, the 4 machines are isolated. No internet access.
    A friend suggested setting up one or more boxes as bridges.
    Is one inherently simpler to do than another?
    I'm doing some OS/middleware fault testing and the switch/hub
    needs to be eliminated as a variable (for good or ill)

    Matthew Clark, Mar 10, 2006
  5. Matthew Clark

    Eric Teuber Guest

    Sorry, i do not understand your question. Please be more precisely.

    Eric Teuber, Mar 10, 2006
  6. Matthew Clark

    Tauno Voipio Guest

    You won't. The hosts are much more probable to create
    faults than a simple hub. A switch is more complicated
    than a hub, but still much simpler than a bridged
    (link level forwarding) or routing (network level
    forwarding) host.
    Tauno Voipio, Mar 10, 2006
  7. Matthew Clark

    Postmaster Guest


    1. It's possible.
    2. It's a bad idea.
    3. For $10 you could use get a switch.
    4. If A is talking to C and D wants to talk with B, you've
    got bandwidth problems that could have been avoided
    for $10.
    5. If you're really going here then you might want another
    connection from A to C, and from D to B. Then the
    max hop would be 1 (one). But your cost in NICs will
    far exceed the cost of 4 port switch :) (12 versus 4)

    Postmaster, Mar 10, 2006
  8. Matthew Clark

    Eric Teuber Guest

    AFAIK, also hosts can be set as routes, if there is now default gateway
    using the same network mask.
    Eric Teuber, Mar 10, 2006
  9. Matthew Clark

    Tauno Voipio Guest

    Yes - Google for bridging.

    It can even do some packet filtering on the way.
    Google for 'ebtables'.
    Tauno Voipio, Mar 10, 2006
  10. I meant do you know if bridging is easier to set up than IP forwarding,
    or more reliable, etc.

    Matthew Clark, Mar 10, 2006
  11. Matthew Clark

    Rick Jones Guest

    Just like they used to do with pt-pt links in the old days :) They
    could even all be in the same IP subnet if you really needed them to
    be. The hard part would be if you wanted "fail over" so A could say
    still reach C if B went down by using D instead of B to get there.

    rick jones
    Rick Jones, Mar 10, 2006
  12. Matthew Clark

    Eric Teuber Guest

    Thanks Matthew for the extra explanation.
    I don't think so. Forwarding will be much easier to implement.

    Eric Teuber, Mar 10, 2006
  13. I can't get into specifics, but suffice to say I would if I
    could, but I can't, so I won't ;)

    Matthew Clark, Mar 10, 2006
  14. Switches and hubs are a fact of life. If the software you
    are debugging/working on can't handle them, then I
    would say "it sucks".

    ***** charles, Mar 11, 2006
  15. If you don't at least explain why you can't use the normal solution,
    nobody will be able to do a good job of finding you the right abnormal
    solution. If you can't walk, but won't tell us whether it's because your leg
    is broken, it's too far, or the terrain is inhospitable, how can we know
    whether to tell you to get someone to carry you, take a car, or fly a plane?

    David Schwartz, Mar 11, 2006
  16. Matthew Clark

    Cat Guest

    I would go for bridging with STP. It's a simple and versatile solution
    that automatically handles the rendundancy and avoids having to
    manually manage IP blocks, etc.

    Look at: http://linux-net.osdl.org/index.php/Bridge and make sure you
    turn STP on. (It is off by default!)

    Watch out for the learning state which lasts a few seconds after you
    enable a bridge. Only when all ports enter the forwarding state will
    you be able to ping and exchange any other network traffic.

    Cat, Mar 12, 2006
  17. Should be possible may different ways.

    [1] You may need cross over cables (ususally PC to switch is a straight

    [2] If you do not need box formation or want to turn routing protocols
    on, then connect (D-A) as 192.168.1.x, (C-B) as 192.168.2.x, and connect
    (A-B) as 192.168.3.x, then put route of 192.168.3.x as the way to get to
    2.x on 1.x boxes and also 1.x on 2.x boxes. Confused ?

    [3] If you want box then (C-D) could be 4.x and you could route 1.x to
    2.x through 4.x or 3.x to get to each other.
    Craig Andersen, Mar 12, 2006
  18. Thanks. A co-worker keeps insisting that you can't assign IP's to
    NIC's being used as a bridge and I'm not quite savvy enough to
    disabuse him of the notion. (If this were image processing, I'd set
    him square ;-) At the risk of looking even more like a Mongo,
    what's the rebuttal?

    Matthew Clark, Mar 13, 2006
  19. Matthew Clark

    Cat Guest

    The idea is that when you bridge two physical adapters (call them eth0
    and eth1), you should no longer touch them. The "bridge" is represented
    to the network stack as a new, virtual adapter, called for example,
    br0. All networking should be done through that adapter from then on.

    Practically, this means:
    - Set up your bridge (eth0 + eth1 => br0) before you set IP addresses;
    eth0 and eth1 must not have IPs when in the bridge.
    - Set up static IPs, or DHCP, or whatever you want, on br0. Treat it
    just like any "normal" interface; now the bridging code automagically
    sends your packets on the correct physical interface. In fact, that is
    the fundamental function of a bridge or a switch.

    This scheme effectively maintains the semantics of a single-homed host,
    since while you have two level-2 networking interfaces, you're only
    accessing a single level-3 network.

    Cat, Mar 13, 2006
  20. Why would you want to?

    David Schwartz, Mar 13, 2006
    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.