Welcome! Log In Create A New Profile


Bluetooth PAN / internet access point

Posted by mawe3661 
Bluetooth PAN / internet access point
November 27, 2010 02:43AM
I an trying to set up debian on my dockstar to be an internet acces point using a bluetooth adapter. This may also be reffered to as setting up a PAN with the dockstar acting as a NAP. Anyway, I cannot find updated instructions of how to accomplish this, and I would greatly appreciate some help. There is a great guide at http://en.gentoo-wiki.com/wiki/Set_up_a_bluetooth_NAP which I think work except that network configuration on Gentoo and Debian seem different. Especially it is the section http://en.gentoo-wiki.com/wiki/Set_up_a_bluetooth_NAP#Setting_up_a_network_bridge which is different. Could anyone translate this into a description for debian?

Thanks in advance!

Re: Bluetooth PAN / internet access point
December 03, 2010 02:05PM
Here's a brief list of steps I took to enable NAP functionality on my dockstar.

This requires a couple of packages to be installed beforehand:
  • bridge-utils
  • bluetooth
  • bluez
  • bluez-utils
  • python
  • python-dbus
  • python-gobject
Bridge Configuration
Setting up the bridge is the easier part, so we get through with that first.

Replace the eth0 configuration with br0 in /etc/network/interfaces:
auto lo br0
iface lo inet loopback
iface br0 inet dhcp
    bridge_ports eth0
    bridge_fd 5
    bridge_stp no
This defines bridge br0 and adds eth0 as the first interface. Several sources on the 'net recommend to set bridge_fd to 5 or even 0. I didn't care much, so I took a less aggressive value. It's important to not configure eth0 anywhere in the file.
Keep in mind that restarting /etc/init.d/network will most likely void your current ssh session. Typos in interfaces might further block networking and network access to your dockstar. So either perform this step from a serial connection or ensure that you can fix the file offline (removable media, etc.).
If everything went ok, things work as before and ifconfig lists br0 with an assigned inet address.
$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.0010751adc57       no              eth0

Bluetooth Configuration
Bluez stores the per-adapter configuration in /var/lib/bluetooth/<adapter-MAC>. Never ever modify any files there! You'd get inconsistent and unreproducible results.

Announce br0 as the NAP interface in /etc/bluetooth/network.config. Everything else can stay the same in the installation template:
# Configuration file for the network service

# This section contains options which are not specific to any
# particular interface

# Disable link encryption: default=false

[PANU Role]

# Network interface name for PANU for connections. default:bnep%d
# (up to 16 characters)

# PAN user connection interface up script. default:none

[GN Role]

# Network Interface name for Group Network server. default:pan0

# Group Network connection interface up script. default:none

[NAP Role]

# Network Interface name for Network Access Point server. default:pan1

# Network Access Point connection interface up script. default:none
We don't care about the PANU interface name. The default naming scheme is ok.

Ensure that the bluetooth daemon is running:
/etc/init.d/bluetooth start
If not yet done, insert your bluetooth adapter now and get your PAN client ready (cell phone, PDA, ...).

The bluez installation comes with a couple of test scripts that serve as a very basic interface to the bluez dbus-API. They're installed in /usr/share/doc/bluez/examples. cd there to configure the adapter.
Assign a friendly name:
./test-adapter name honeypot
Enable pairing and discovery:
./test-adapter pairable on
./test-adapter discoverable on
./test-adapter discoverabletimeout 30
Setting a discovery timeout is optional here.

You should now be able to discover honeypot from your client device. This and the following strongly depends on the user interface of your client device.
Start the PIN agent on the dockstar:
It'll sit there and wait for pairing requests from a client. So initiate pairing/connecting with honeypot from your device. My cell phone first asks for a PIN code, then the simple-agent is triggered over the air and asks for the same PIN. Enter it and wait for your device to acknowledge the matching PIN. Once pairing is accomplished you can terminate simple-agent.

Trust your mobile device so it can connect in the future without interaction by an agent:
./test-device trusted <client-MAC> yes
You can look-up the <client-MAC> at any time with
cat /var/lib/bluetooth/<adapter-MAC>/names

Now it's time to actually connect your client to the dockstar. Ensure that the client selects the NAP profile and voilĂ , the wireless interface bnep0 pops up and is automatically attached to br0:
Dec  3 21:51:59 dock-box-1 bluetoothd[988]: link_key_request (sba=<adapter-MAC>, dba=<client-MAC>)
Dec  3 21:52:00 dock-box-1 bluetoothd[988]: Added new connection: bnep0
Dec  3 21:52:00 dock-box-1 kernel: [86681.186494] device bnep0 entered promiscuous mode
Dec  3 21:52:00 dock-box-1 bluetoothd[988]: bridge br0: interface bnep0 added
Dec  3 21:52:00 dock-box-1 kernel: [86681.197957] br0: port 2(bnep0) entering learning state
$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.0010751adc57       no              bnep0

Congratulations, you have established a transparent link between your bluetooth device and your LAN :-)
Re: Bluetooth PAN / internet access point
December 04, 2010 01:38PM
Thanks! You seem to know what you are doing!

However, I don't get simple-agent to pop the question so to speck. When I try to connect from Ubuntu, I am presented with a 6 digit code that should be entered on the NAP, but simple-agent does not ask me the question (it does say "Agent registered"). Can you give me some advice on that?

I also found another way to configure /etc/network/interfaces:

auto eth0
iface eth0 inet manual

auto bridge0
iface bridge0 inet dhcp
  pre-up ifconfig eth0 down
  pre-up brctl addbr bridge0
  pre-up brctl addif bridge0 eth0
  pre-up ifconfig eth0 up
  post-down ifconfig eth0 down
  post-down brctl delif bridge0 eth0

auto pan1
iface pan1 inet manual
  pre-up brctl addbr bridge0
  pre-up brctl addif bridge0 $IFACE
  up ifconfig $IFACE up
  down ifconfig $IFACE down
  post-down brctl delif bridge0 $IFACE

# The loopback network interface
auto lo
iface lo inet loopback

What's the main difference? That appears to be working as well.

Re: Bluetooth PAN / internet access point
December 05, 2010 04:01AM
I'd expect simple-agent to query for the PIN once the client (Ubuntu in your case) challenges the dockstar with this 6 digit code.
What happens when you acknowledge Ubuntu's requester? Any reaction from simple-agent?

Concerning interfaces, there's not much I could add. The minimal configuration works for me and I ignored the additional bridge pan0 that's been added for the [GN Role]. Your example looks far more elaborate but I can't tell what the benefit is. Maybe some networking expert can comment on this.
Re: Bluetooth PAN / internet access point
December 05, 2010 08:09AM
I finally got it working using your descriptions! I had to remove the /var/lib/bluetooth/xx:xx:xx:xx:xx directory in which I had edited files myself. When doing that all is now working. I alse subsequently had an issue with a Belkin BT adapter (F8T016) which I could pair but then not connect. Using the adapter in windows with the right drivers made it work however, so I think that was an Ubuntu specific problem with that adapter.

Regarding config of interfaces I think the simpler the better!

Thanks for your help!
Re: Bluetooth PAN / internet access point
September 03, 2011 05:52AM
Thank you for pointing out the script test-adapter.
After upgrading my Debian NSLU2 NAS to from Lenny to Squeeze, it no longer workes as a bluetooth access point. I'd been struggling to get it to work for months now. Now it's working again :) Thank you so much!
Re: Bluetooth PAN / internet access point
November 01, 2012 03:51PM
how can I create bluetooth PAN on my Samsung Galaxy Pocket (an android phone)? Plz, help me.

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.