Bluetooth tethering with blues-tools and Cyanogenmod

I have to admit that I kind of like Bluetooth technology. It works great for a wireless mouse, and I also use it to tether my Android phone which is running Cyanogenmod 7.2. Here is how.

First, we need to pair the devices, the process which I have already described. To recap:

$ bt-adapter -d   # note the MAC address in the output
$ bt-device -c <MAC address>
$ bt-device --set <MAC address> Alias desire

Here I’ve chosen “desire” as an alias for my phone (it’s an HTC Desire). Once the devices are paired, the rest is easy. The important command is bt-network -c <alias> nap. I’ve written a small script to wait for bluetooth connection and to launch dhcp client once it is established:


DHCP_CMD="sudo dhclient -d bnep0"
BT_CMD="bt-network -c desire nap"
CONNECTED="Network service is connected"


trap cleanup TERM INT EXIT

$BT_CMD >$out 2>&1 &

cleanup () {
    rm $out > /dev/null 2>&1

echo -n "*** Waiting for bluetooth connection..."

for i in $(seq $RETRIES); do
    if grep "$CONNECTED" $out >/dev/null 2>&1; then
        echo "\n*** Bluetooth connection established:\n"
        cat $out
        echo "\n*** Running dhcp client:\n"
    if [ ! -d /proc/$bt_pid ]; then
        echo "\n*** Bluetooth connection died, exiting. Output:\n"
        cat $out
        exit 1
    sleep 1
    echo -n "$i "

Here is the normal output of the script:

$ ./
*** Waiting for bluetooth connection...1 2 3 4
*** Bluetooth connection established:

Network service is connected
Interface: bnep0
UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)

*** Running dhcp client:

Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit

Listening on LPF/bnep0/cc:af:78:e4:e3:ef
Sending on   LPF/bnep0/cc:af:78:e4:e3:ef
Sending on   Socket/fallback
DHCPREQUEST on bnep0 to port 67
bound to -- renewal in 1520 seconds.

And here is the notification that appears on the phone screen once the connection is established:

Update 11 May 2013

I recently realized that, at least on a Debian system, the shell script above is not really necessary.

Instead, add the following 2 lines to the /etc/network/interfaces file:

allow-hotplug bnep0
iface bnep0 inet dhcp

To start the tethering, simply use the bt-network command directly:

bt-network -c <alias> nap

As soon as the bluetooth network interface bnep0 appears, it will be auto-configured with dhcp thanks to the entry in the /etc/network/interfaces file.

blog comments powered by Disqus