Linux – How to Tether an Android Phone to Linux with Bluetooth and Internet Access

bluetoothlinuxrouter

The web is chock-full of explanations on how to tether device so-and-so (including Linux-based devices) to an Android phone providing the Internet uplink.

I'd like to do it the other way around. I'd like to be able to use a small Linux-based router with a Bluetooth dongle as the uplink for my Android phone, tethering my Android phone via Bluetooth PAN.

I can set up the Android side. How do I set up the GNU/Linux side?

  1. Is this at all currently possible?
  2. How do I do it?

I am running Android 10 (the connecting device) and I am flexible with the Linux side (currently it's either Debian or OpenWRT, depending on the device I try) offering the tether via Bluetooth and the uplink as well as routing.

NB: I'd like to emphasize that I am not interested in WiFi-based solutions. I need this via Bluetooth, i.e. PAN.

Best Answer

Looks like you need something like this (Let me copy the relevant part here, just in case):

First of all, you need to enable BT PAN support in your OPENWRT firmware:

$ git clone https://git.openwrt.org/openwrt/openwrt.git/
$ cd openwrt
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a
$ cp enable_btpan_usbrndis_for_wzr-hz-g300nh.seed .config
$ make defconfig
$ make

After flashing your image to router, use bluetoothctl to turn on your dongle

bluetoothctl power on

ssh login to OpenWrt and set NAP UUID to bluetoothd:

dbus-send --system
--dest=org.bluez /org/bluez/hci0
--type=method_call
org.bluez.NetworkServer1.Register
string:“00001116-0000-1000-8000-00805f9b34fb”
string:"br-lan"

Check, if bluetoothd supports NAP role by running bluetoothd show. It should show something like this:

Controller 00:1B:DC:06:61:D4 (public)
Name: BlueZ 5.49
Alias: BlueZ 5.49
Class: 0x00020000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6

Set your device (phone) as trusted in advance (substitute MAC with your own, obviously):

root@OpenWrt:~# bluetoothctl
[bluetooth]# trust 00:02:5B:00:A5:A5
[CHG] Device 00:02:5B:00:A5:A5 Trusted: yes
Changing 00:02:5B:00:A5:A5 trust succeeded
[bluetooth]#

Make BT discoverable on OpenWrt router and pair to it from Android device. Then tick "Use for Internet access" checkbox in device properties.

bnep0 interface, belonging to br-lan bridge should appear in OpenWRT at this stage.

Related Question