I have two different networks (separate LANs), each with their own ISP gateway, that I want to cross (users from one LAN to reach the other LAN). The ISP gateways are stupid branded home gateways without any fancy functionalities (e.g. static routing).
Basically the current topology is:
LAN1 -> ISP_G1 -> WAN LAN2 -> ISP_G2 -> WAN
I want to be able to cross the LANs but keeping the WAN traffic to each one of them. My idea is to use a Linux machine as a router/dhcp server, in order to keep WAN connectivity to each LAN, but also be able to e.g. ping from one LAN to another.
The topology that I am trying this is:
WAN -> ISP_G1 -> LAN1/Switch1 -> Linux/Router <- LAN2/Switch2 <- ISP_G2 <- WAN
The Linux/Router machine has two Ethernet interfaces, each connected to the different LANs, and also serves as the DHCP server giving two different subnets to the clients from each LAN.
The addressing is the following:
Linux/Router machine: eth0: 10.0.0.2 eth1: 10.0.1.2 ISP gateways: ISP_G1: 10.0.0.1 ISP_G2: 10.0.1.1
DHCP in the ISP gateways is turned off, instead the Linux machine is the DHCP server giving IPs to clients according to the different subnets e.g. 10.0.0.0/24 and 10.0.1.0/24. Also it tells to the clients that their gateway is not the ISP gateways but the Linux machine itself, e.g. 10.0.0.2 for LAN1 and 10.0.1.2 for LAN2.
My problem is that only one LAN can have access to both subnets and their WAN, and this depends on which WAN gateway is configured on the Linux machine.
For example: If the Linux machine is configured with ISP_G2 as its gateway, LAN1 can access LAN2 but cannot access the WAN, and vice versa.
I am trying to designate a different gateway based on route tables on the Linux machine e.g.:
ip route add default via 10.0.0.1 dev eth0 table subnet1 ip rule add from 10.0.0.0/24 table subnet1
But then while LAN1 can access the WAN through the ISP_G1, it can no longer access LAN2.
What I need is a way to change the LAN1 gateway to ISP_G1, ONLY for traffic that is meant for the WAN, and keep the Linux machine as the LAN1 gateway for all LAN related traffic.
Any pointer is greatly appreciated