Comments on Bluetooth PAND (Personal Area Network) Howto For Debian Etch
Bluetooth PAND (Personal Area Network) Howto For Debian Etch 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.
10 Comment(s)
Comments
Inspired by this HOWTO, I had another go at setting up a PAN: and this time, finally, after years of failure, I managed to get things working! I used a somewhat simpler approach, so maybe this should be incorporated...
I would suggest using ipmasq instead of iptables and dnsmasq instead of dhcp3-server. Both of these are "I'm just an ordinary user, quit bugging me and give me my damn internet already!"-oriented packages which use sensible defaults and keep configuration to a minimum.
So, as you suggest:
lm accept,master
PAND_ENABLED=1
PAND_OPTIONS="--listen --role=NAP --devup /etc/bluetooth/pan/dev-up"
For /etc/bluetooth/pan/dev-up, my version boils down to just the following:
#!/bin/sh ifup --force $1
It relies on the ifupdown system for setting up masquerading and DHCP, so it only has to ifup the device. Also, pand supplies two arguments to this script: the first is the name of the Linux device (i.e., "bnep0"), the second is the connecting phone's MAC address. Using the argument instead of hard-coding bnep0 is cleaner and should make this part work smoothly even with multiple connections (although I've never tried that, and you'd still have to set up extra /etc/network/interfaces.)
I found I needed the --force flag because once the device is brought up, it's never cleanly brought down again. The device just disappears, but this seems to confuse the ifupdown system, which thinks it's still configured. Then, when another connection comes in, the ifupdown system thinks it doesn't need to do anything, and the device remains unconfigured. So I use --force to make it configure the device anyway. In upstream (at least bluez-utils 3.10) they seem to have added a hook to pand to allow it to run a script when the device is shut down, as well as when it's brought up. That should allow the device to be brought down cleanly by a /etc/bluetooth/pan/dev-down script, and remove the need for the --force flag. But we'll have to wait before that makes it into stable.
I'd also mention that I experimented with simply doing this:
PAND_OPTIONS="--listen --role=NAP --devup /sbin/ifup"
...which avoids the need for a separate script. This does actually work (it complains about the nonsense MAC argument, but this is benign). But I couldn't find a way to get the --force argument in there, so for me this would only work once.
So then we come to /etc/network/interfaces:
iface bnep0 inet static address 192.168.65.1 netmask 255.255.255.0 up /usr/sbin/ipmasq down /usr/sbin/ipmasq
In this case I've gone for 192.168.65.0/24 as my bluetooth network. The up and down commands are as recommended by the package maintainer of ipmasq (see /usr/share/doc/ipmasq/README.Debian.gz). The down command is a little pointless, since this interface will never be brought down cleanly, but what the hell.
And finally, /etc/dnsmasq.conf:
dhcp-range=192.168.65.50,192.168.65.150,12h
Obviously this has to be adjusted for whatever network you chose in /etc/network/interfaces. This gives you a DHCP server on the specified interface, and it also provides a forwarding DNS server. Note that it pretty much takes care of itself, it doesn't need to be told about new interfaces coming up or going away.
Thanks for the HOWTO!
Hi!
Excellent article. Worked for me after I kept at it for sometime. I now have a bluetooth tether going between my PC (it is connected to internet) and my tablet. I am able to ping my tablet from my PC. I am able to access a webpage hosted on my PC from my tablet too.
But my PC uses a proxy server to access the internet. My tablet does not have a way of specifying proxy settings. Is it possible to handle the packet forwarding to the proxy in the DHCP configuration itself? Please suggest a way to do this or suggest an alternative.
Thanks!
Well done!!! This worked for me and after several times of trying to make this thing work on my slackware I made it finally because of this great post.
Worked on Ubuntu Intrepid.
I had to add in /etc/bluetooth/network :
Interface=pan0
because bluetoothd try to use the bridge pan1: from syslog:
Can't add bnep0 to the bridge pan1: No such device(19) Hope this helps.
Are you sure this works in Ubuntu 8.10? As far as I can tell the bluetooth statck between 8.04 and 8.10 is totally different ... i.e. there is no hcid and hcid.conf in 8.10.
I get the same error you mentioned (bnep0) but chancing the Interface to pan0 does not work either...
Any ideas?
Cheers,
-e
Hi,
I am getting the same error as you are, however, your solution apparently does not help. Could you please be a bit more elaborate ?
You are talking about the network.conf file in /etc/bluetooth right ?
And you changed the Interface value to pan0 for the NAP Role ?
Thanks, I will hugely appreciate any input
Kaustubh
I've tried this with my Debian Etch and Acer Bluetooth Adapter but my bnep0 never comes up and with my notebook I don't see my PC. So does anybody know what I could have forgot?
This line
chmpd +x /etc/bluetooth/pan/dev-up
Should be
chmod +x /etc/bluetooth/pan/dev-up
Otherwise this works great in Arch Linux
but i d not think many people will do like this.it is just a little complicated
can someone please update this for the debian jessie?
bluez-utils does not exist anymore