Can’t connect to LAN and internet at same time

Network

I can't connect to a local network with ethernet and internet through WiFi at same time on macOS. The normal reordering solutions don't work. Here is the first few lines of routing table:

➜ netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            10.100.8.1         UGSc          165        0     en0
default            10.125.32.1        UGScI           8        0     en7

The first entry is my WiFi network through which I can normally access internet, and second is the restricted local ethernet connection.

Currently whichever one is set higher in priority works and it seems like I should be able to somehow get it setup to have them both function simultaneously. To clarify, by function I mean I can access intranet sites on ethernet and access regular internet through WiFi.

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 8c:85:90:cd:ac:f9
    inet6 fe80::9b:9439:d9a8:cf6f%en0 prefixlen 64 secured scopeid 0x8
    inet 10.100.10.27 netmask 0xfffff800 broadcast 10.100.15.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active

en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=4<VLAN_MTU>
    ether a0:ce:c8:17:94:d3
    inet6 fe80::1c6f:20f:65a0:5374%en7 prefixlen 64 secured scopeid 0x11
    inet 10.125.32.139 netmask 0xfffffc00 broadcast 10.125.35.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (100baseTX <full-duplex>)
    status: active

Best Answer

This is usually caused by having the wrong subnet masks specified for the networks.

In your case with IP-adresses 10.100.8.1 and 10.125.32.1 you'll probably the subnet mask set to 255.0.0.0 (/8) for both networks - that is incorrect.

Change the subnet masks so they are for example 255.255.0.0 (/16) instead, and you'll be able to route normally.

Remember to only set a default gateway in the subnet associated with the interface you actually want to use as an Internet connection.