I have an IoT device that runs a small HTTP server, which I access through Ethernet.
My Ethernet is routed through 192.168.1.3 and configured manually.
I can access the device with no issues when my Wi-Fi is turned off:
curl 192.168.1.2/?connect
response OK
This is the content of my routing table when my Wi-Fi is off and Ethernet is connected (en4):
netstat -nr
Routing tables
Internet:
Destination Gateway Flags Netif Expire
127 127.0.0.1 UCS lo0
127.0.0.1 127.0.0.1 UH lo0
169.254 link#7 UCS en4 !
192.168.1 link#7 UCS en4 !
192.168.1.1 link#7 UHLWI en4 !
192.168.1.2 2:4c:db:14:60:9a UHLWIi en4 1174
192.168.1.3/32 link#7 UCS en4 !
192.168.1.3 5c:85:7e:3e:99:f4 UHLWI lo0
192.168.1.99 link#7 UHRLWI en4 !
192.168.1.219 link#7 UHRLWI en4 !
192.168.1.226 link#7 UHRLWI en4 !
192.168.1.230 link#7 UHRLWI en4 !
224.0.0/4 link#7 UmCS en4 !
224.0.0.251 1:0:5e:0:0:fb UHmLWI en4
255.255.255.255/32 link#7 UCS en4 !
Everything works fine as long as I only use my Ethernet. However, as soon as I activate my Wi-Fi, I lose connection and cannot access my device anymore. Curl hangs and timeouts.
This is the content of my routing table after activating my Wi-Fi (en0):
netstat -nr
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.1.1 UGScg en0
127 127.0.0.1 UCS lo0
127.0.0.1 127.0.0.1 UH lo0
169.254 link#4 UCS en0 !
169.254 link#7 UCSI en4 !
192.168.1 link#4 UCS en0 !
192.168.1 link#7 UCSI en4 !
192.168.1.1/32 link#4 UCS en0 !
192.168.1.1 ac:d5:64:fe:e2:e7 UHLWIir en0 1185
192.168.1.2 link#4 UHLWIi en0 !
192.168.1.3/32 link#7 UCS en4 !
192.168.1.3 5c:85:7e:3e:99:f4 UHLWIi lo0
192.168.1.99 60:ab:d2:fb:73:2f UHLWIi en0 1154
192.168.1.184/32 link#4 UCS en0 !
192.168.1.185 84:f7:3:a9:83:e0 UHLWI en0 1183
192.168.1.213 34:b4:72:f:ab:94 UHLWI en0 1176
192.168.1.219 d4:f5:47:29:3b:3c UHLWIi en0 1154
192.168.1.226 1c:53:f9:4:32:ff UHLWIi en0 1150
192.168.1.230 a4:77:33:9a:1b:30 UHLWIi en0 1185
192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI en0 !
192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI en4 !
224.0.0/4 link#4 UmCS en0 !
224.0.0/4 link#7 UmCSI en4 !
224.0.0.251 1:0:5e:0:0:fb UHmLWI en0
239.255.255.250 1:0:5e:7f:ff:fa UHmLWI en0
239.255.255.250 1:0:5e:7f:ff:fa UHmLWI en4
255.255.255.255/32 link#4 UCS en0 !
255.255.255.255/32 link#7 UCSI en4 !
I have tried to set up a static route to map my IoT device to the Ethernet Gateway (en4), which adds the following line to the routing table:
192.168.1.2 192.168.1.3 UGHS en4
However, I still receive no response from the device.
I suspect that my HTTP calls are being routed through my Wi-Fi instead of reaching my Ethernet connection.
How can I configure my routing table to ensure that traffic is sent to my device via Ethernet?