Scripting Bluetooth Hotspot for Mobian
#1
We already have almost everything we need here.
I want to get Bluetooth hotspot working on my Mobian/Pinephone, Bluetooth tethering a laptop or tablet while on the train, hotel, during a power outage, or at coffee is a basic daily driver phone requirement in my opinion.
I am sure the modern kernel has the required modules but I don't know what the interface name for bluetooth network interface for the pinephones bt driver; bnep0 is the interface used on this old N900 script.
I think this is an easy edit to the other network interfaces like USB already in the wiki unless iptables has changed much since the 2010s.

BT PAN tethering is by far the best and easiest way to tether to your phone's internet connection vs WiFi which wastes far more electricity per Mb transmitted for little benefit other than maybe easier sharing a wifi password with friends vs them having to pair with you on BT.  The security is provided by the bluetooth pairing process.

Below is the scripting to get full service, including DHCP, automatic Bluetooth PAN hotspot running on the Nokia N900, how much will work as is?.  

Code:
install the iptables package:

apt-get install iptables

create the following 2 files:

/etc/udev/rules.d/98-bnep0.rules:

ACTION=="add", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"
ACTION=="remove", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"

/etc/udev/bluenet.sh:

#! /bin/sh
if [ $ACTION = "add" ]; then
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING ! -o lo -j MASQUERADE
    ifconfig bnep0 192.168.3.1
    ifconfig bnep0 up
    /usr/sbin/dnsmasq -I lo -z -a 192.168.3.1 -F 192.168.3.64,192.168.3.127 -x /var/run/dnsmasq.pid.bnep0
else
    iptables -t nat -D POSTROUTING ! -o lo -j MASQUERADE
    if [ -f /var/run/dnsmasq.pid.bnep0 ]; then
        DNSMASQ_PID=`cat /var/run/dnsmasq.pid.bnep0`
        rm -f /var/run/dnsmasq.pid.bnep0
        kill $DNSMASQ_PID
       fi
fi

then set /etc/udev/bluenet.sh as executible:

chmod +x /etc/udev/bluenet.sh

now whenever an authorised remote device makes a bluetooth pan (nap) connection iptables and dnsmasq are setup to allow that device access to the phones network. TODO: when no internet connection is active ask to set it up

The mobian wiki has instructions for USB, and LAN, WIfi hotspot is included but bluetooth PAN entry is not yet explained in the wiki.
https://wiki.mobian-project.org/doku.php...networking
  Reply


Messages In This Thread
Scripting Bluetooth Hotspot for Mobian - by biketool - 03-14-2022, 10:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mobian, Suspend, and Audio Playback biketool 0 78 12-11-2024, 12:56 AM
Last Post: biketool
  Upgrade to Mobian (Trixie) Staging biketool 12 608 12-06-2024, 05:46 PM
Last Post: vusra
  how to update mobian over tor vusra 14 9,384 12-04-2024, 07:01 PM
Last Post: vusra
  bookworm vs trixie discussion for mobian in pinephone regular. zetabeta 41 9,143 11-27-2024, 10:39 AM
Last Post: fernando_c_m
  atinout binaries for mobian/debian? NeutralGrey 4 1,479 10-31-2024, 04:16 AM
Last Post: astylethargic
  Mobian-Kicksecure? 3460p 0 887 05-26-2024, 02:09 PM
Last Post: 3460p
  Mobian repository status henrythemouse 16 12,333 04-10-2024, 10:02 AM
Last Post: diederik
  cant verify mobian image at website gnugpg penguins_rule 0 941 03-18-2024, 08:54 PM
Last Post: penguins_rule
  mobian installed to eMMC - how to install tow-boot grump_fiddle_reinstall 6 4,083 11-22-2023, 11:46 AM
Last Post: aLoop100o
  What actions needed to keep on mobian testing user641 3 2,656 09-05-2023, 06:44 AM
Last Post: Zebulon Walton

Forum Jump:


Users browsing this thread: 1 Guest(s)