1

I have two routers, one for internet another one for intranet. enter image description here

Is it possible to connect a LAN cable between router 1 and router 2 to have both internet and intranet access at the same time?

I tried disabling the DHCP in router 1, and I gained access to the intranet but lost access to the internet. And vice versa.

How to properly set it up? I have openwrt installed on both routers.

Update 2024-03-10

Based on the answer and another post, I have modified my network config a bit, now I can get access to the internet but I can't get access to the intranet. enter image description here

I think I am missing the explicit route setting mentioned by @sleepyhead which I am not sure how to do it in openwrt. I tried to do the setting below but it still doesn't grant me access to the intranet. enter image description here

2
  • What is the "Router 2 WAN" network address range? (And is it really a "WAN"?) Commented Mar 9 at 12:28
  • The devices under the intranet all start with 43.xx.xx.xx. By "WAN", I mean there is an Ethernet cable connecting to the WAN port of router 2 to get access to the intranet. Commented Mar 9 at 14:22

1 Answer 1

1

Setup routes for each device. Your laptop will probably use router1 as default route. From there router 1 needs an explicit route for the IP addresses on the intranet to router 2. Probably the return path from your intranet doesn't know the addresses from your own network, router 2 should act as a NAT towards the intranet.

IP routing is hop-by-hop, each device should know which next hop traffic to and from each network should be routed

Edit based on your updated picture: Because the laptop is now in the same 192.168.1.0/24 network as your router 2, you can tell the laptop that everything routed to 43.6.20.0/24 should be routed to 192.168.1.1, the default is to use 192.168.1.2 for anything else. router 1 doesn't need to do any IP routing anymore, it just needs to act as a network switch. The explicit route was needed to route between 192.168.1.0/24 and 172.168.1.1 which I now realize was a typo. Your route in openwrt would have been almost correct, you would have to set the gateway. But if router 1 and 2 are in the same IP network, it's not relevant anymore

For IP routing what matters is that each hop can reach the next IP hop., each hop needs needs a router to the next neighbor. For you the laptop and router 2 are in the same IP network, so either on your laptop you have a route for 43.6.20.0/24 via router 2 or you send by default everything to router 1 and there route 43.6.20.0/24 via gateway 192.168.1.2

On router 2 you need a NAT to reach 43.6.20.0/24

On your laptop, you would need static routes like this.

route add 43.6.20.0/24 via 192.168.1.1

route add default via 192.168.1.2

the exact syntax between operating systems and network manager differ.

With explicit I meant that the route needed to be specified by yourself, because packets would otherwise by default sent to the wrong network branch. It's static because you don't use routing protocols to announce routes, hardly anybody does unless you have a bigger network.

3
  • I tried setting the explicit route in openwrt, but I am not sure if I am doing it correctly. Please see my updated post. Commented Mar 10 at 13:19
  • Your updated solution works for me! It seems even if I don't set NAT on router 2, as long as the ip routing 43.6.20.0/24 via 192.168.1.1 and default via 192.168.1.2 are set on my laptop, everything works already. Is NAT really needed here? Commented Mar 14 at 12:13
  • Yes NAT is needed, because it's unlikely that your corporate will route back to your local subnet. Openwrt probably does it by default so you wouldn't have to set it. 192.168.0.0/16 and 172.16.0.0/12 are private address ranges, any address is only locally relevant. Good to see things working for you!
    – sleepyhead
    Commented Mar 15 at 7:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .