2 separate WANs and LANs on a single OpenWrt router

Hi, I have 2 different networks each with its own WAN and LAN subnets and I am trying to use a single multi-ports OpenWRT router to house both networks. I have gotten almost everything figured out but could not find a way to define the default gateway to each network individually. To give a clearer example:

eth0: WAN1 IP address: (dhcp assigned by provider1)
eht1: LAN1 IP address: (static, dhcp server enabled in OpenWRT)
eth4: WAN2 IP address: (dhcp assigned by provider2)
eth5: LAN2 IP address: (static, dhcp server enabled in OpenWRT)

How can I set all traffic on LAN1 gateway pointing to WAN1, and LAN2 gateway pointing to WAN2? I am not trying to do any load balancing or fail over from WAN1 to WAN2, just 2 distinct networks.

Can anyone help? Thanks!

You can implement policy-based routing (PBR) using routing rules in UCI, or use a package which supports PBR.

In the first case you configure ip4table (and ip6table) on each WAN interface and then add one rule for each LAN which selects the correct table.

1 Like

Thanks! Let me try PBR now, never use it before.