Bluetooth PAND (Personal Area Network) Howto For Debian Etch

Overview

I wanted to access the internet over bluetooth instead of GPRS/3G network from my mobile phone (SE K800i). After a lot of searching I couldn't find a clear explanation as how to accomplish this. I did manage to set it up with Windows XP, using the "Personal Area Network" in the bluetooth utility and doing internet connection sharing. After another fruitless search, I managed to figure out how to make a bluetooth internet profile instead of GPRS or 3G on the phone. Since I work in Linux most of the time, I decided to have a go and do it with Debian, my workstation's main OS. After spending a few hours, I had it working using the steps below.

This howto is for Debian Etch, current "testing" branch soon to be 4.0. May work on Ubuntu or other Debian based distros. Settings for older versions may be similar. In Debian 3 the bluetooth daemon maybe regarded to as hcid.

Requirements

  • Kernel 2.6.x, may work under 2.4, not tested.
  • iptables is needed if you want to access other computers or the internet.

Install:

apt-get install bluetooth
install apt get install bluez-utils
install apt-get install dhcp3-server

Optional:

apt-get install kdebluetooth

Has the kde pinhelper application for easy pairing.

Note: Pairing your bluetooth devices is beyond the scope of this howto. It assumes you can pair you device to your system.

As root:

Edit /etc/bluetooth/hcid.conf. Change

lm accept;

to

lm accept, master;

Edit /etc/default/bluetooth.Change

PAND_ENABLED=0

to

PAND_ENABLED=1

and

PAND_OPTIONS=""

to

PAND_OPTIONS="--listen --role=NAP --devup /etc/bluetooth/pan/dev-up"

mkdir /etc/bluetooth/pan
touch /etc/bluetooth/pan/dev-up

Put the following in /etc/bluetooth/pan/dev-up:

#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
ifup bnep0
sleep 2
/etc/init.d/dhcp3-server restart

Make it executable:

chmpd +x /etc/bluetooth/pan/dev-up

In /etc/network/interfaces add the bluetooth interface as follows:

iface bnep0 inet static
          address 10.0.254.1
          netmask 255.255.255.240
		  
post-up iptables -t nat -A POSTROUTING -s 10.0.254.0/24 -j MASQUERADE
post-up iptables -A FORWARD -i bnep0 -o eth0 -j ACCEPT
post-up iptables -A FORWARD -o bnep0 -i eth0 -j ACCEPT
pre-down /etc/init.d/dhcp3-server stop

eth0 is the interface you will be NAT-ed behind. Your external interface.

Change the IPs and network settings as you like, just make sure to also reflect it in your dhcp.

In /etc/dhcp3/dhcpd.conf make sure you set

option domain-name "somedomainname.com";
option domain-name-servers ip-of-dns-server-goes-here;

where ip-of-dns-server-goes-here is the IP address of the dns server to use. You can see the server you're using in /etc/resolv.conf.

Declare a subnet for the PAN segment, should be the subnet you used for the bnetp device in /etc/network/interfaces. Replace the option routers 10.0.254.1; with the IP you have given your bnep0 interface in /etc/network/interfaces.

subnet 10.0.254.0 netmask 255.255.255.0 {
  range 10.0.254.1 10.0.254.10;
  option domain-name-servers 10.0.1.1;
  option domain-name "bluetoothap.int.yourdomain.com";
  option routers 10.0.254.1;
  option broadcast-address 10.0.254.255;
  default-lease-time 600;
  max-lease-time 7200;
}

Now restart the bluetooth daemon:

/etc/init.d/bluetooth restart

Pair your device with the machine. Once paired you should be able to access the network using the bluetooth PAN service for another computer, PDA or mobile phone.

Troubleshooting

1. See if your bnep0 device is going up when a connection is requested and the interface is asked to come up. You can watch this with the following command as root:

watch -n1 “ifconfig”

You should see bnep0 coming up when you fire up your bluetooth client device to try and access the PAN network.

2. See that the script /etc/bluetooth/pan/dev-up is being executed.

3.Watch the output of syslog to see if the dhcp server is asinign an IP to your device.

tail -f /var/log/syslog
tail -f /var/log/messages

4. Once you see the IP, try to ping your device with the ping command.

Bluetooth PAN settings for Sony Ericsson k800i

Menu:

Settings -> Connectivity -> Data Accounts.

In the list you should see your bluetooth AP.

Go to

 Settings -> Connectivity -> Internet Settings -> Internet Profiles -> New profile

In Name enter a name for the connection. eg. PAN.

For Connect Using choose the bluetooth icon with the name of your bluetooth machine, the one showing in the data accounts, and also the PC you paired your k800i with.

Now make this profile active for internet, java and streaming.

Make sure you press save.

Now you should be able to browse the internet trough your k800k. Enjoy!

 

Written by Zdenek Bouresh.

zdenekbouresh [at] gmail dot com  

Share this page:

10 Comment(s)