immortalwrt / homeproxy

The modern ImmortalWrt proxy platform for ARM64/AMD64 (powered by sing-box)
GNU General Public License v2.0
532 stars 159 forks source link

Homeproxy Not Functioning with Load Balancing Enabled in mwan3 Configuration #35

Closed devAlikhani closed 11 months ago

devAlikhani commented 1 year ago

I have encountered an issue where homeproxy does not function as expected when load balancing is enabled in my mwan3 configuration. The issue is as follows:

config member 'wan_member'
    option interface 'wan'
    option metric '1'
    option weight '1'

config member 'wanb_member'
    option interface 'wanb'
    option metric '1'
    option weight '1'

config rule 'default_rule_v4'
    option dest_ip '0.0.0.0/0'
    option use_policy 'load_balanced'
    option family 'ipv4'
    option proto 'all'
    option sticky '0'

config policy 'load_balanced'
    list use_member 'wan_member'
    list use_member 'wanb_member'
    option last_resort 'unreachable'

I expected homeproxy to work seamlessly alongside load balancing, allowing traffic to be load-balanced between the wan and wanb interfaces for other general network traffic.

However, the actual behavior is that homeproxy is completely blocked and can't send any packet.

+0000 2023-09-27 20:59:18 ERROR [3319903261 1.25s] inbound/redirect[redirect-in]: process connection from 192.168.2.172:64224: dial tcp 45.141.21.54:443: connect: no route to host
+0000 2023-09-27 20:59:21 ERROR [3606825731 1.13s] inbound/redirect[redirect-in]: process connection from 192.168.2.172:64239: dial tcp 45.141.21.54:443: connect: no route to host
+0000 2023-09-27 20:59:21 ERROR [3620684452 2.97s] inbound/redirect[redirect-in]: process connection from 192.168.2.172:64233: dial tcp 45.141.21.54:443: connect: no route to host

of course, when disabling homeproxy, load-balancing works correctly.

1715173329 commented 1 year ago

homeproxy will detect (and set fixed) outbound interface by default to avoid traffic loop. Unfortunately it won't work with load balancing.

Comment out the following line may help https://github.com/immortalwrt/homeproxy/blob/e66fe2ac84ec5b545d7dc18b4b4fd1f886ebe8f0/root/etc/homeproxy/scripts/generate_client.uc#L504

devAlikhani commented 1 year ago

I tried the suggested solution, but it was unsuccessful. Is there a method to modify the 'sing-box' inbounds to direct traffic to a localhost SOCKS proxy, or another way to manage the output traffic of mwan3?

1715173329 commented 1 year ago

I'm not sure what do you mean by "modify inbounds". Anyway, mwan3 or something like that, are never ever considered - and won't be considered.

devAlikhani commented 1 year ago

@1715173329, based on your answer, homeproxy will not support mwan3. I'm considering an alternative network topology with two WAN and two LAN interfaces. With homeproxy running on each WAN and directing packets to their respective LANs, each LAN would have its own DHCP server with a distinct IP range. After the homeproxy has applied its proxy node on the traffic, I plan on handling load balancing externally using a Mikrotik router.

Is binding each node to its respective WAN interface and running two nodes simultaneously on homeproxy in this setup feasible?

1715173329 commented 1 year ago

homrproxy does support bind specific interface for each node (custom routing), but looks like it becomes more complex.

v2rayA may work for you.