Linux – Connect two subnets without router

linuxrouting

I got two Comcast routers with two different subnets on each. Every subnet contains 5 static IPs. Two questions:

  1. Are there any problems if both routers and machines from both subnets are connected into one switch? Security issues doesn't matter there. I need to know if there are some performance or other problems.
  2. Is it possible to make machines from different subnets to see each other if they all are connected into one switch? Some static routing, add ARP records or somethig else …

I just want to avoid configuring second ethernet adaptors, third router or something. And I need to connect these subnets vai high-speed local network.

Best Answer

  1. Generally speaking the largest concerns when two subnets exist on the same layer 2 domain are related to security, and broadcast domain size. Since you've stated security isn't a concern in your environment, and there's only a dozen or so devices in question, I would not anticipate a performance hit for your proposal.
  2. What you're trying to accomplish is no different than trying to route a specific subnet to a gateway other than your default. In this scenario you need to instruct the device that the destination in question is available through it's Ethernet port. This will cause the device to resolve the layer 3 address to it's layer 2 destination with ARP.

On Windows this is accomplished with the following command:

route add 10.10.10.0 mask 255.255.255.0 if 1

Replace the destination address and subnet mask accordingly. The number following "if" represents an internal representation of the interface you wish to use. On the hosts I tried 1 always found my first Ethernet adapter, but your mileage may vary.

On Linux this is accomplished with the following command:

route add -net 10.10.10.0 netmask 255.255.255.0 dev eth0

Again, replacing the address and netmask where applicable. The designation of the Ethernet interface to use is much easier to ascertain here.