3
3
On Ubuntu 14.04 x86-64 I have a wireless broadband connection and a USB tethered one (it's on 4G, not the same wireless):
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.42.129 0.0.0.0 UG 0 0 0 usb0 192.168.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan1 192.168.42.0 0.0.0.0 255.255.255.0 U 1 0 0 usb0
I have then the following also:
ifconfig ... usb0 Link encap:Ethernet HWaddr 02:36:2c:04:05:7c inet addr:192.168.42.248 Bcast:192.168.42.255 Mask:255.255.255.0 inet6 addr: fe80::36:2cff:fe04:57c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3367 errors:1 dropped:0 overruns:0 frame:1 TX packets:3669 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2434689 (2.4 MB) TX bytes:637911 (637.9 KB) wlan1 Link encap:Ethernet HWaddr 14:cc:20:75:e1:8d inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::16cc:20ff:fe75:e18d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3806 errors:0 dropped:0 overruns:0 frame:0 TX packets:4110 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2283536 (2.2 MB) TX bytes:583794 (583.7 KB)
It all looks like it's supposed to be working as intended (i.e. both network connections are up, my machine got 2 IPs, ...).
Then I wanted to use the bind shim to force processes on one connection (or another) and those only work when I specify the IP of the default connection/gateway.
The following works (please note this is on the tethered USB - 4G):
BIND_ADDR="192.168.42.248" LD_PRELOAD=./bind.so chromium-browser
And this doesn't (my broadband):
BIND_ADDR="192.168.0.4" LD_PRELOAD=./bind.so chromium-browser
Of course, when I unplug the USB phone, wlan0 magically starts working again...
What am I doing wrong? Any idea?
From the looks of it, your .0.0 route doesn't work when you're bound to the 42.0 network because your default route points to a gateway at 42.129, which you can't access on the other network. You need a route for 0.0.0.0/0 on 192.168.0.0/24, probably whatever your router is. – Xyon – 2015-12-26T15:47:45.813
@Xyon How can I verify that? Even if I use the bind shim? That LD_PRELOAD trick is supposed to force all binds and connect to 192.168.0.4? – Emanuele – 2015-12-26T15:50:54.803
Well it not pulling external sites suggests that it is working, because otherwise you'd get connectivity through the other link. Your broadband network isn't completely set up, I don't know how bind is supposed to handle that situation but the kernel doesn't know where to send your packets. – Xyon – 2015-12-26T15:52:32.800
@Xyon I guess I'll have to write a simple test executable to see what errors the kernel is returning when creating TCP/UDP connections? – Emanuele – 2015-12-26T15:53:46.190
No, I wouldn't go that far. What you're trying to do needs a second route table, bound to your other interface, so the system understands how to handle requests from each interface. See https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System for a good resource on the concept.
– Xyon – 2015-12-26T15:55:54.797Pls read my answer. – MariusMatutiae – 2015-12-26T16:00:06.170
You both are right, in fact if I use BIND_ADDR="192.168.0.4" LD_PRELOAD=./bind.so firefox, I can open the broadband router just fine (on 192.168.0.1). – Emanuele – 2015-12-26T16:34:07.067
@MariusMatutiae would this do it in one line:
ip route add from 192.168.0.0/24 gw 192.168.0.1 dev wlan1
or maybeip route add from 192.168.0.0/24 via 192.168.0.1
? – Emanuele – 2015-12-27T10:24:58.477