When you use Bluetooth for network services (as opposed to wireless microphone, wiresless mouse, etc), you are using its PAN, or Personal Area Network profile. PAN is provied by the PAN daemon, pand, from the bluez-utils package. PAN uses the BNEP protocol. BNEP stands for Bluetooth Network Encapsulation Protocol.
Kernel configuration
Get a recent 2.6.x kernel, and enable the following features, either as module or built-in:- CONFIG_BRIDGE_NETFILTER
- CONFIG_BT
- CONFIG_BT_L2CAP
- CONFIG_BT_RFCOMM
- CONFIG_BT_BNEP
- CONFIG_BT_HCIUSB
Debian packages
Install the following Debian packages:- bridge-utils (for brctl)
- bluez-utils (for pand)
Configuration files
- Edit /etc/bluetooth/hcid.conf to set class to 0x020100;
- Edit /etc/default/bluez-utils to set PAND_ENABLED=1 and PAND_OPTIONS="--listen --role NAP"
- Create /etc/bluetooth/pan/dev-up with this contents:
#!/bin/sh
ifconfig $1 0.0.0.0
brctl addif br0 $1
- Add a bridge as a network interface to /etc/network/interfaces by using something like this (I use 192.168.192.x as my local address space).
auto br0
iface br0 inet manual
up echo "Adding ethernet bridge between LAN and PAN"
up ifconfig eth0 0.0.0.0
up brctl addbr br0
up brctl setfd br0 0
up brctl stp br0 off
up brctl addif br0 eth0
up ifconfig br0 192.168.192.1 netmask 255.255.255.0 up
down echo "Removing ethernet bridge between LAN and PAN"
down ifconfig br0 down
down brctl delif br0 eth0
down brctl delbr br0
Operation
First check, whether your USB dongle has been detected by the kernel. You can check this by running 'hciconfig -a'. You should get information on the hci0 interface. Now, if a client bluetooth device will request network service, the PAN daemon, pand, will respond to this. Check your process list to see if pand is running. If not, '/etc/init.d/bluez-utils start' is required. Once the two bluetooth devices connect, a network device called 'bnep0' is created, and pand will execute the /etc/bluetooth/pan/dev-up script. In this script, we will bridge the newly created bnep0 to eth0, using the bridge called br0. To kill the connection at either side, run 'pand -K'.Clients
A linux client for the bluetooth network, can connect to the server by using this command:pand --nodetach --role PANU --searchUPDATE: I've found that I need to have 'dbus' installed to get rid of the error "Inquiry failed. No such device" I recently experienced. Without dbus, /etc/init.d/bluetooth would fail.
Notes
Don't forget that your dhcpd server should now listen on the bridge br0, not on the LAN eth0. Edit /etc/init.d/dhcpd to change this.The whole deal with the bridging is required, so that dhcpd can function regardless wether bnep0 exists or not. You cannot bring up dhcpd to listen on bnep0, if there is no bluetooth PAN connection. You can, however, have dhcpd listen on the br0 bridge, and attach it to bnep0 whenever a bluetooth client connects.
If you experience troubles, check the /var/log/daemon.log file for more information.
No comments:
Post a Comment