I'm having a bluetooth enabled [embedded] Linux device and would like to share it's internal Network (NOT connected to the internet) via Bluetooth to Android devices (tried Android 6.x and now 7.1.2 - Lineage OS [rooted]). The setup already works well with Linux or Windows Clients. I read through tons of postings and documentations but I just cannot get it to work with Android devices:
My Linux-Device: dnsmasq as DHPC Server, Bluetooth Enabled and "bt-pan" [1] is up and running (the bridge interface is called bt-pan0
). Via Dbus-Events I automatically "trust" any new connected device. Device-Class (if that matters) is configured with hciconfig to 0x020000.
On my Android phone, I pair (which works automatically) and connect (use "Internet Access") with my Linux-Device (Hotspot). In the dnsmasq log I see that the connected device gets an IP address properly.
From the linux-box I can ping the mobile phone on the published IP address and I see a new bnep0
device being created and added to the bt-pan0
bridge.
When I connect via adb shell
to my phone, I also see a bt-pan
device being created with the correct IP/Netmask setup as provided by my dnsmasq.
Unfortunately when Wifi or Mobile-Data are enabled - I cannot ping the linux-box via it's IP address. When Wifi and Mobile-Data are disabled - the setup works fine.
Here is the output of a few commands I executed via adb shell
- if more output is required I'll provide it ASAP (Mobile-Data IP address is modified by me while pasting):
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 * 255.255.255.0 U 0 0 0 bt-pan
123.456.78.16 * 255.255.255.252 U 0 0 0 rmnet_data0
# ip route get 192.168.10.5
192.168.10.5 via 123.456.78.18 dev rmnet_data0 src 123.456.78.17 uid 0
cache
# ip rule show
0: from all lookup local
10000: from all fwmark 0xc0000/0xd0000 lookup legacy_system
10500: from all oif dummy0 uidrange 0-0 lookup dummy0
10500: from all oif rmnet_data0 uidrange 0-0 lookup rmnet_data0
10500: from all oif bt-pan uidrange 0-0 lookup bt-pan
13000: from all fwmark 0x10063/0x1ffff lookup local_network
13000: from all fwmark 0x100b9/0x1ffff lookup rmnet_data0
13000: from all fwmark 0x100ba/0x1ffff lookup bt-pan
14000: from all oif dummy0 lookup dummy0
14000: from all oif rmnet_data0 lookup rmnet_data0
14000: from all oif bt-pan lookup bt-pan
15000: from all fwmark 0x0/0x10000 lookup legacy_system
16000: from all fwmark 0x0/0x10000 lookup legacy_network
17000: from all fwmark 0x0/0x10000 lookup local_network
19000: from all fwmark 0xb9/0x1ffff lookup rmnet_data0
19000: from all fwmark 0xba/0x1ffff lookup bt-pan
22000: from all fwmark 0x0/0xffff lookup rmnet_data0
23000: from all fwmark 0x0/0xffff uidrange 0-0 lookup main
32000: from all unreachable
In the dnsmasq configuration for the bt-pan0
device I set an empty default-gw (dhcp-option 3) and a proper DNS server (dhcp-option 6).
I read about setting dhcp-option 121 (classless static routes) but that didn't work neither (the DHCP-request does not query for 121)...
If someone has any idea what is going on or knows why this setup is causing issues - I would be very happy to finally figure that out.
ip a
in addition toip r
. In particular, bt-pan did get an address assigned from 192.168.10.0/24? From the current output it is unclear whyip r get 192.168.10.5
would yield dev rmnet_data0. The marking rules of iptables and the other routing tables (e.g.,ip route get table bt-pan
) are required to fully understand what is going on. Note thatip route get
accepts a 'mark' option and a 'oif' option, seeip r help
. So I guess thatip route get 192.168.10.5 oif bt-pan
would give a route via dev bt-pan. – Ambitendencyip route get table bt-pan
didn't work thus I attachedip route show table all
. Hope this is helpful - thanks! pastebin.com/Lw8ZkHH8 – Northington