Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Having two LAN, each one have its own gateway, DHCP and internet connexion

  • LAN 1 - IPs: 192.168.0.0-255, Mask: 255.255.254.0, Gateway: 192.168.0.1
  • LAN 2 - IPs: 192.168.1.1-255, Mask: 255.255.254.0, Gateway: 192.168.1.1

Connect them with a linux computer having two NIC, one for each LAN. The NIC connected to LAN 1 accept all packets sent to 192.168.1/24 (ips of LAN2) and sends them with the other NIC and vice-versa. It is seen as being all the other computers.

Is this possible ? Wich command should I type in the linux box to setup this "routes". The goal is that each LAN stay with their DHCP, current gateway and internet connexion, but able to reach the computers of the other LAN.

Please, don't tell me it is not the academic way to do it. The question is about guessing if this setup is possible or not and pointing out what will prevent it from working. I know it is not the usual way to do it, that it is not pretty, that I should setup routes on the gateways... But I want to have gigabit troughput and the routers are too weak for this.

EDIT AFTER QUESTION HAS BEEN CLOSED:

Despite the really hostile reactions this question rised, I managed to find an answer. What I was describing is called a pseudo-bridge. I managed connecting the subnets using a dual port NAS (Synology ds1812+). One port connected to each network and enabling both ip_forwarding and proxy_arp.

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/eth1/proxy_arp

Works like a charm at Gigabit speed and for free. Thanks to mfinni for shouting the answer in comments (as question was closed).

More info there http://www.cisco.com/en/US/tech/tk648/tk361/technologies_tech_note09186a0080094adb.shtml, http://en.wikipedia.org/wiki/Proxy_ARP and there http://www.sjdjweis.com/linux/proxyarp/

share|improve this question

closed as off-topic by MDMarra, Dave M, pauska, Chris S Oct 3 '13 at 14:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – MDMarra, Dave M, pauska, Chris S
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Why are you using /23 netmasks? –  EEAA Oct 3 '13 at 12:57
1  
So computers from LAN 1 do not sent packets for 192.168.1.x to the gateway. They send them directly to the connect box that emulate all 192.168.1.x IP. –  bokan Oct 3 '13 at 13:00
4  
So computers from LAN 1 do not sent packets for 192.168.1.x to the gateway. They send them directly to the connect box that emulate all 192.168.1.x IP You're doing it wrong. Configure additional non-default routes on your routers for the other subnets and point those routes to the server's interface on the subnet if you have to do it like this. –  MDMarra Oct 3 '13 at 13:15
9  
Each time someone designs a network like this the gods will kill kittens.. by the dozens.. –  pauska Oct 3 '13 at 13:48
2  
This is a unbelievable kludge and not how IP is intended to function. The reasoning on why you do it this way is just stupid; if you want your throughput, it can be done in a proper way. You will run into problems, just like you would when using a wrench as a hammer: it does work somehow, but don't expect your wrench to be useful for a prolonged time. –  Roman Oct 4 '13 at 8:15

2 Answers 2

You're doing it wrong. If you've got a single /23 as you describe, then you don't need to route between the two. If they're on physically separate subnets and you have two /23s with the same IP space, then you just created IP address space overlap and it will be a nightmare. Stick to /24s here (or other non-overlapping subnets).

If you really want to do this with a Linux box between the two, enable IP Forwarding and create routes between the two routers using the appropriate interfaces. It will probably look something like this

Subnet1 Router <-----> |eth0 (on subnet 1) LinuxRouter eth1(on subnet 2)| <-----> Subnet2 Router

Don't try and do this the way you're doing it. Use /24s (or other non-overlapping space) and have the routes in your routers for the other subnets point to the Linux router's interface for that subnet.


Edit: To actually answer your somewhat crazy question, no this will not work the way you're asking. If a computer is 192.168.0.2/23 and it wants to communicate to 192.168.1.2/23, it will assume that this is a computer on the local subnet (because you've told it that it is) and it will not send that traffic to a gateway to be routed, whether that gateway would be your router or a server that is doing routing. Again, don't do this.

share|improve this answer
    
You're telling me to do it the usual way, passing trafic trough the routers. The question asks wether it is possible to do it another way. DHCP range ensure no IP off subnet 2 is lent on subnet 1. –  bokan Oct 3 '13 at 13:19
4  
@bokan It sounds like you really should consider hiring a network consultant or take some classes in this field. If this is for a workplace, you sound like you're about to make a complete mess out of it. Ask your supervisor for some more training, please. I'm not trying to be rude but you appear so far out of your element here that it can only end badly. –  MDMarra Oct 3 '13 at 13:31
2  
You seem to have completely lost your mind with this. You're going to assign 255 IPs to each interface of this linux box? I'm sorry. I can't help you any more, this is getting ridiculous. –  MDMarra Oct 3 '13 at 13:54
3  
PROXY ARP ALL THE THINGS. –  mfinni Oct 3 '13 at 14:21
4  
Under no circumstances will this be re-opened. This is the worst possible way you can accomplish this and anyone with a clue would not do this in a production environment. Server Fault is for professional networks, not tinkering. To open this would he telling people that this is a reasonable solution. It's not. Just because you can make something work doesn't mean that you should. –  MDMarra Oct 4 '13 at 11:16

Besides all the reasons stated that you probably shouldn't do it, you can make it work. but you would need to add routes to each and every host on the subnets.

You would also have to Change to /24 subnet masks as opposed to the current /23 you are using or else it probably won't work as the the host computers will not make a routing decision since the other IPS would appear local.

So that being said assuming you change the masks to /24 and assuming your have your linux box with interfaces 192.168.0.2 and 192.168.1.2 with routing enabled between them.

Then on each host on the 192.168.0/24 subnet you would

route 192.168.1.0/24 to 192.168.0.2

and each host on the 192.168.1/24 subnet you would

route 192.198.0.0/24 to 192.168.1.2

now when the host makes a routing choice it will send it to the GW you specified as opposed to using the default.

share|improve this answer
    
I want the other IP to appear local and the linux box to have them all (192.168.0.1-255 on one side 192.168.1.1-255 on the other) then forward packets to the other side. I can confirm that your suggestion of adding route to pcs works, I tested it already :) –  bokan Oct 3 '13 at 13:46
    
well if you want to remove routing out of the way, you are going to have to do weird stuff with bridging, and the even then I not sure how you would do ti. –  Doon Oct 3 '13 at 13:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.