Bluetooth PAN network tethering

As far back as the Maemo-Linux Nokia N900 we have had a FOSS option to install and configure bluetooth tethering using the Personal Area Network profile. Using bt vs wifi is a major A/hr savings when on battery, it is quite secure, and easy to use once configured.

This is the PAN setup guide for Maemo Linux from around 2011(have to get past the old HTTPS certs) pre-systemd arm debian fork

https://bugs.maemo.org/Bluetooth_PAN

This is mostly a setup of iptables and some bluetooth or bluez config. When I had a pinephone I got as far as getting the PAN bluetooth link and networking working but for some reason never solved why I couldn’t get the link between the BT PAN and the cellular modem’s internet connection unless I SSH’ed into the phone with the -D and connected to that socks5 proxy as a crude hack.

2 Likes

MTU, perhaps?

2 Likes

Ideally I would have made a working dhcp and network tunnel, but when I wiped and started again I must have missed a step in my notes. I never got it that close to working again using bluez(I could have been hacking at the configs themselves?) despite trying over the space of five years occasionally. It needs to be said that I don’t mentally visualize things like iptables very well and I am stuck cutting and pasting the work of others and praying too often.

2 Likes

OK I think I have it working; lets test this and add it to PureOS… Mobian too!

sudo modprobe bnep
echo ā€œbnepā€ | sudo tee /etc/modules-load.d/bnep.conf
sudo hciconfig hci0 up
bluetoothctl

(in the [bluetooth] dialog type)

power on

(then end [bluetooth] session type)

exit

Lets make a personal area network

sudo sdptool add NAP

sudo nmcli connection add type bluetooth con-name "PAN-Share" ifname bnep0

bluetooth.type nap ipv4.method shared

sudo nmcli connection up "PAN-Share"

Now to keep it all after reboot

sudo apt install iptables-persistent

sudo netfilter-persistent save

crossposted to BT PAN - we need iptables and BT hackers

4 Likes

Is there an easy way to add an on/off button in the notification area or BT settings?

reality is the pairing process is enough GUI ad then when needed the client computer can connect to PAN as needed and the host phone can disconnect a problematic paired client completely.

2 Likes

I have had opportunity to use this with my ubuntu-mate (no snap) laptop several times with no issue, just pair and start ā€˜pureos network’ in the network app in mate, my mobile provider is crap so not surprised at the sow speeds especially during power outages.
I also have a pinetab2 with danctnix which seems to have network connection problems though a working bluetooth driver was only made available in that OS a few months ago.

1 Like

I forgot to post that you need to sudo apt install bluez-tools

Great, I borked my system over in the multimedia fix thread, fixed that hosing my in-call audio.
Wiped and reinstalled PureOS, now either I missed a step or something as get this error now

modprobe: ERROR: could not insert 'bridge': Exec format error

Sadly this is a very important tool for me as the Librem5 has a short enough battery life as it is without also using wifi to bridge my cellular data to my computer or tablet, I just uses it last week during a power outage.
I dont know why bridge mode worked before…
(some notes)
The NetworkServer1 D-Bus API was removed from BlueZ 5, which is why it fails. Modern systems use bt-network command instead. cant get bridge nat or nap to work as I fumble with workarounds…idk… frustrating as I followed the above and it worked on the previous install, digging through openwrt docs I feel like one step before was finding arcane packages which hid the BT tools I needed and I didn’t doc them here…
Has anyone else tried and succeeded getting a working Bluetooth PAN access point using my instructions or others?

modprobe: ERROR: could not insert ā€˜bridge’: Exec format error

Something’s messed up with your kernel. It works on stock linux-image-6.12.0-1-librem5 6.12.94pureos1~cri1 in crimson.

1 Like

I tried this on a fresh OS install. I have everything saved, for several hours I dug troubleshooting everything scouring openwrt to get it fixed. I probably borked something by trying everything…
@dos Since this is and has long been my own project(since we got this from TMO for the N900) thanks for not just the look but taking the time to go so far as to test.

Perhaps the kernel version in the fresh install is older than the kernel version that dos mentioned? It could be worth checking at least, see what uname -a says. (Not sure how it is right now, but at some point a while back when I reflashed I needed to also do ā€œapt update && apt upgradeā€ afterwards to get the latest versions of everything.)

1 Like

I will check && compare once I am home but fresh USB install Reflashing the Librem 5 – Purism with immediate apt upgrade should give me the freshest crimson AFAIK.
(edit)
Linux pureos 6.12.0-1-librem5 #2 SMP PREEMPT 6.12.94pureos1~cri1 2026-07-01 04:02:34 UTC aarch64 GNU/Linux

1 Like

So I apparently did something wrong and was thus getting this response to the commands I though was the complete install & setup above.

purism@pureos:~$ sudo sdptool add NAP

sudo nmcli connection add type bluetooth con-name "PAN-Share" ifname bnep0 

bluetooth.type nap ipv4.method shared

sudo nmcli connection up "PAN-Share" 
Error: Failed to add 'PAN-Share' connection: bluetooth.type: property is missing
-bash: bluetooth.type: command not found
Error: unknown connection 'PAN-Share'.

whe I entered this sudo nmcli connection add type bluetooth con-name "PAN-Share" ifname bnep0 this after conditions is apparently what was missing bluetooth.type nap ipv4.method shared likely what I missed since this DID work on the previous install, not sure how I missed that when I made the above, I was nearly considering another wipe and reinstall as PAN is mission critical for me due to frequent power blackouts or running from solar power.
I ended up getting PAN Bluetooth access point working use this format:

sudo apt install bluez-tools

sudo modprobe bnep
echo "bnep" | sudo tee /etc/modules-load.d/bnep.conf
sudo hciconfig hci0 up
sudo systemctl enable --now bluetooth

sudo nmcli connection add type bluetooth con-name "PAN-Share" ifname btnap0 bluetooth.type nap ipv4.method shared
sudo nmcli connection up "PAN-Share"

sudo apt install iptables-persistent
sudo netfilter-persistent save

My only question is if bluez-tools was the only thing I installed when I first tried this so feedback please.

1 Like