Outbound to different WAN according to LAN IP

I have subscribed to services from 2 ISPs.

I want some LAN IPs going through WAN-1, some going through WAN-2.
I don't need load-balancing or fail-over.
Is it possible to achieve this by setting "static routing" in OpenWRT?

Thanks.

Should be, or you could provide different default gw to the clients going through the 2nd wan connection, in the DHCP.

WAN (WAN6) and HKT4 (HKT6) are the ISPs.

HKT4 IP is 42.2.122.x

The route is not working.

# cat /etc/config/network 

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'ddaa:4c73:0693::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	option multicast_to_unicast '0'
	list ports 'eth2'
	list ports 'eth3'
	list ports 'eth4'

config device
	option name 'eth1'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth2'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth3'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth4'
	option macaddr '94:83:c4:18:9d:18'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option isolate '0'
	option ipaddr '192.168.50.1'
	option ip6hint '0000'
	option ip6ifaceid '::1'
	option ip6assign '64'
	option ip6class 'local'

config device
	option name 'eth0'
	option macaddr '94:83:c4:18:9d:17'

config interface 'wan'
	option device 'eth0'
	option proto 'dhcp'
	list dns '1.1.1.1'
	list dns '1.0.0.1'
	option peerdns '0'
	option ipv6 '1'

config interface 'wan6'
	option proto 'dhcpv6'
	option device '@wan'
	option disabled '0'

config switch
	option name 'switch0'
	option reset '0'
	option enable_vlan '0'

config interface 'tethering6'
	option proto 'dhcpv6'
	option device '@tethering'
	option disabled '0'

config interface 'wwan6'
	option proto 'dhcpv6'
	option device '@wwan'
	option disabled '0'

config interface 'guest'
	option force_link '1'
	option type 'bridge'
	option proto 'static'
	option ipaddr '192.168.9.1'
	option netmask '255.255.255.0'
	option multicast_querier '1'
	option igmp_snooping '0'
	option isolate '0'
	option bridge_empty '1'
	option ip6prefix 'ddaa:4c73:0693::/48'
	option ip6assign '64'
	option ip6hint '0001'
	option ip6ifaceid '::1'
	option ip6class 'guest'

config interface 'wwan'
	option proto 'dhcp'

config rule 'policy_bypass_vpn'
	option mark '0x60000/0x60000'
	option lookup '53'
	option priority '53'

config rule 'policy_via_vpn'
	option mark '0x80000/0x80000'
	option lookup '52'
	option priority '52'

config rule 'policy_dns'
	option mark '0x100000/0x100000'
	option lookup '51'
	option priority '51'

config interface 'wgserver'
	option proto 'wgserver'
	option config 'main_server'
	option disabled '0'

config interface 'zerotier'
	option device 'ztklhx37yn'
	option proto 'none'

config interface 'HKT4'
	option device 'eth1'
	option proto 'dhcp'
	list dns '1.1.1.1'
	list dns '1.0.0.1'
	option peerdns '0'

config interface 'HKT6'
	option proto 'dhcpv6'
	list dns '2606:4700:4700::1111'
	list dns '2606:4700:4700::1001'
	option reqprefix 'auto'
	option reqaddress 'try'
	option peerdns '0'
	option device '@HKT4'

config route
	option target '0.0.0.0/0'
	option gateway '42.2.122.1'
	option source '192.168.50.3'
	option interface 'HKT4'

Which route?

Is your DHCP suggestion only available through command line?

What option, the local mind reader's on vacation....

All traffic from 192.168.50.3 should go through ISP "HKT4".

config route
	option target '0.0.0.0/0'
	option gateway '42.2.122.1'
	option source '192.168.50.3'
	option interface 'HKT4'

Strange. The "Reply" button does not quote your message...

The quote button quotes text...

1 Like

Is it available on OpenWRT UI? Or command line only?

All traffic from 192.168.50.3 should go through ISP "HKT4".

config route
	option target '0.0.0.0/0'
	option gateway '42.2.122.1'
	option source '192.168.50.3'
	option interface 'HKT4'

I have tried this:

But there is no Internet connection on 192.168.50.3.

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'ddaa:4c73:0693::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	option multicast_to_unicast '0'
	list ports 'eth2'
	list ports 'eth3'
	list ports 'eth4'

config device
	option name 'eth1'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth2'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth3'
	option macaddr '94:83:c4:18:9d:18'

config device
	option name 'eth4'
	option macaddr '94:83:c4:18:9d:18'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option isolate '0'
	option ipaddr '192.168.50.1'
	option ip6hint '0000'
	option ip6ifaceid '::1'
	option ip6assign '64'
	option ip6class 'local'

config device
	option name 'eth0'
	option macaddr '94:83:c4:18:9d:17'

config interface 'wan'
	option device 'eth0'
	option proto 'dhcp'
	list dns '1.1.1.1'
	list dns '1.0.0.1'
	option peerdns '0'
	option ipv6 '1'

config interface 'wan6'
	option proto 'dhcpv6'
	option device '@wan'
	option disabled '0'

config switch
	option name 'switch0'
	option reset '0'
	option enable_vlan '0'

config interface 'tethering6'
	option proto 'dhcpv6'
	option device '@tethering'
	option disabled '0'

config interface 'wwan6'
	option proto 'dhcpv6'
	option device '@wwan'
	option disabled '0'

config interface 'guest'
	option force_link '1'
	option type 'bridge'
	option proto 'static'
	option ipaddr '192.168.9.1'
	option netmask '255.255.255.0'
	option multicast_querier '1'
	option igmp_snooping '0'
	option isolate '0'
	option bridge_empty '1'
	option ip6prefix 'ddaa:4c73:0693::/48'
	option ip6assign '64'
	option ip6hint '0001'
	option ip6ifaceid '::1'
	option ip6class 'guest'

config interface 'wwan'
	option proto 'dhcp'

config rule 'policy_bypass_vpn'
	option mark '0x60000/0x60000'
	option lookup '53'
	option priority '53'

config rule 'policy_via_vpn'
	option mark '0x80000/0x80000'
	option lookup '52'
	option priority '52'

config rule 'policy_dns'
	option mark '0x100000/0x100000'
	option lookup '51'
	option priority '51'

config interface 'wgserver'
	option proto 'wgserver'
	option config 'main_server'
	option disabled '0'

config interface 'zerotier'
	option device 'ztklhx37yn'
	option proto 'none'

config interface 'HKT4'
	option device 'eth1'
	option proto 'dhcp'
	list dns '1.1.1.1'
	list dns '1.0.0.1'
	option peerdns '0'

config interface 'HKT6'
	option proto 'dhcpv6'
	list dns '2606:4700:4700::1111'
	list dns '2606:4700:4700::1001'
	option reqprefix 'auto'
	option reqaddress 'try'
	option peerdns '0'
	option device '@HKT4'

config route
	option target '0.0.0.0/0'
	option interface 'HKT4'
	option table '1024'

config rule
	option lookup '1024'
	option src '192.168.50.3/32'
	option priority '1024'

you can try use mwan3 & luci support to add static policies for some LAN IPS, it will automatically add routeing table and firewall rules to achieve what you intend to do. Though it's originally used for loadbalancing.