I am not sure, for once, if this is a proper answer. I will make up for whatever is missing as we move on.
You have no VPN configured whatsoever. You routing table is correct for a pc connected to a local LAN, nothing else.
It is possible that the error is rooted in the fact that you seem to have (please correct me if I am wrong) the very same subnet at home and at work: 192.168.1.0/24. I deduce this from your current routing table, and from this statement of yours:
But when I go to Go > Connect to Server and try to connect using the local address (that works when I am at the office:
afp://192.168.1.104
.....
If this is the case, no matter what other errors you may have in the configuration of the VPN, it will not work. In fact, there might be pcs with the same IP addresses, and in any case, when confronted with an address like, for instance, 192.168.1.104 your kernel, your local router, your remote router, will be unable to understand whether you are referring to an IP address this side of the tun0, or on the opposite side.
If I am right on this (same subnet for home and work), then we will be unable to make progress until this is sorted out.
The reason why your bind does not work has nothing to with bind, a trick I use too, and everything to do with the fact that you have only one default gateway, on the usb0
NIC, while you should have one on either NIC, otherwise connection to WAN sites from wlan0
will not be routed.
Linux allows the existence of multiple gateways (one per interface, virtual or not), under the regimen of policy-based routing
. What you need to do is to have two separate routing tables, one for usb0
and one for wlan0
, and a rule telling the kernel which one to use; then binding
an application to either interface will allow you to reach WAN sites.
You handle two routing tables as follows: First, create two tables (Replace and with sensible names, same with IP1, DEV1, and so on):
echo 200 <NAME1> >> /etc/iproute2/rt_tables
echo 201 <NAME2> >> /etc/iproute2/rt_tables
Add a gateway to each routing table (if needed):
ip route add <NET1> dev <DEV1> src <SRC1> table <NAME1>
ip route add <NET2> dev <DEV2> src <SRC2> table <NAME2>
Then a default route:
ip route add default via <IP1> table <NAME1>
ip route add default via <IP2> table <NAME2>
Then the rules to select the route table based on the source address:
ip rule add from <IP1> table <NAME1>
ip rule add from <IP2> table <NAME2>
Now you can bind application to either interface.
Best Answer
Most likely the default gateway for that interface. TUN connections usually are p2p connections, which mean they are composed of a range with just 2 IPs, the gateway and the IP address.
You can verify that running
route -n
and seeing that the default gateway for your tun interface is indeed10.8.0.5
.