LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Slackware 13 bluetooth PAN (http://www.linuxquestions.org/questions/slackware-14/slackware-13-bluetooth-pan-759274/)

0rphu 10-02-2009 04:54 PM

Slackware 13 bluetooth PAN
 
Hi all,

I've been tinkering with making the bluetooth pan working for about a week now, managed to get all sorts of outcomes, some of them I can't even reproduce anymore. I also got it running on one occasion with bluez 4.53, but that was only until I rebooted. I haven't been able to get it working again. I want to use my desktop as NAP or GN.

Tried with bluez 3.36, but couldn't even pair the other device (a windows xp notebook or a sony ericsson w902 mobile phone). And even if I could, the pand daemon doesn't work because the network plugin of bluez is blocking a socket for pand. And the network plugin doesn't seem to be working either as I've read.

I tried with bluez 4.53, installed gnome-bluetooth, bluez gnome, even blueman with all that horrifying dependencies like policykit which I don't even know what is for. I was able to pair the device, but only from computer to the phone and sometimes with strange outcomes. The network sharing from computer to phone (or my notebook) didn't work anyway. No bnep0 gets available, only that one time until I rebooted.

So is there a brave soul out there who got it working? I'd be very grateful for any howto, even one including black magic, I am pulling my hair here... It's not a problem for me to reinstall everything and start with a clean install, but I am avoiding KDE, so KDE free pointers are the ones I'd value the most, but this is not a condition.

I hope I am not asking too much, but at the moment my bluetooth dongle is rather useless apart from providing irritating blue light.

Thanks a lot in advance

0rphu 10-03-2009 11:08 AM

OK, I got it working. With a little help from a friend :)
 
If it weren't for cgorac, who probably just registered to the forum and was, like me in need of a bluez related help, I wouldn't manage it at all. Frankly I've just given up when suddenly... But let me give it to you as it should be given - in order.

I made a fresh install, so this should be easy to follow.

1. to make bluetooth services start on boot, you'll need to make /etc/rc.d/rc.bluetooth executable

Code:

chmod u+x /etc/rc.d/rc.bluetooth
2. set your default key (1234 or whatever you like)

Code:

echo -n "1234" >/etc/bluetooth/passkeys/default
3. change your /etc/dbus-1/system.d/bluetooth.conf to allow passkey agent access to dbus (add the red marked line)

Code:

<!-- This configuration file specifies the required security policies
    for Bluetooth core daemon to work. -->

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy user="root">
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent"/>
    <allow send_interface="org.bluez.PasskeyAgent"/>
  </policy>

  <policy at_console="true">
    <allow send_destination="org.bluez"/>
  </policy>

  <policy context="default">
    <deny send_destination="org.bluez"/>
  </policy>

</busconfig>

4. reboot now to make sure the dbus configuration change is loaded

5. After reboot the bluetooth services should be running. To pair your device (desktop, laptop, phone...) provoke the bonding by initiating an obex connection form the computer to the device

5.1 First find out the MAC of the device

Code:

hcitool scan
you should obtain an address of the device

5.2 start the obex connection

Code:

obexftp -b <insert address of the device here> -l
you will be prompted to insert a passkey on you device, insert the one you've set in step 2.

5.3 You should be all good now! Your device is paired.

If you'd like to setup your computer as a NAP, read on.

Some time ago, BlueZ switched from dedicated daemons (like pand) to plugins (like network.so). The only problems are that they either don't work, or I just couldn't find a way how to make them work and even worse, they tend to make the old "legacy" deamons unusable by blocking a socket they use. So how can you solve this? Read on!

6. There are 2 ways to disable the "new" service plugins, like network.so. First is to recompile - this is a nice way, on the other hand, you might break something and lose some functionality by not specifing correct configure parameters or omitting some. Do that if you know exactly what you are doing. I on the other hand have already broken so many BlueZ installations that I don't dare anymore. I'll go the nasty way

6.1 switch to plugins directory
Code:

/usr/lib[64]/bluetooth/plugins/
and you'll see them there. Your arch enemy is network.so and network.la. Rename them. hcid will be very sad that he can't find them and load them and will probably rant about that, but that is his problem, not mine. And you will be able to use the good old pand daemon again.

7. make a "devup" executable file, this will bring your bnep0 interface up assign an IP to it and allow packet forwarding. You can create it wherever you like, just make it owned and executable by root and don't forget to use the whole path to it in step 8 below.

Code:

mkdir /etc/bluetooth/pan/
vi devup

my devup looks like this. Seen it on a gentoo page and works flawlessly for me. This requires some basic knowledge of networking. If you undrestand the code below, you should be able to change it to your liking

Code:

#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward

ifconfig bnep0 192.168.0.2 up

iptables -F
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
iptables -A FORWARD -i bnep0 -o eth0 -j ACCEPT
iptables -A FORWARD -o bnep0 -i eth0 -j ACCEPT

make it executable

Code:

chmod u+x /etc/bluetooth/pan/devup

8. enable pand in /etc/rc.d/rc.bluetooth.conf and set the command options. You'll find it just at the bottom of the config file. Mine look like this
Code:

# The PAN daemon is used to setup a Bluetooth network.
PAND_ENABLE=true
PAND_OPTIONS="--listen --role NAP --devup /etc/bluetooth/pan/devup --persist"

9. restart bluetooth services

Code:

/etc/rc.d/rc.bluetooth restart
10. You are done! Next time your device connects, a bnep0 interface with an assigned IP becomes available on your computer and will be able to forward packets to and from your device. Just make sure you configure your PANu side (another computer or phone) to have an IP from the same subnet as bnep0 and the same DNS server as yours in /etc/resolv.conf.

Last but not least I'd like to thank everyone who made this possible, it's too many of you, most of you are already forgotten names from various forums I've read in the past 2 weeks. If you see something you feel was your idea and would like some credit for it, let me know. Or just feel happy you've helped. I am not taking credit for any of this, I am just glad I got it working. I hope it will help others, too


All times are GMT -5. The time now is 03:06 AM.