View Single Post
Viqsi's Avatar
Posts: 115 | Thanked: 136 times | Joined on Mar 2008 @ Central Ohio
#258
Originally Posted by droll View Post
this works great with a desktop PC. how can i share this with multiple PCs?
I have a multiple-PCs method that doesn't use this script at all - it actually functions automatically once you make the BT connection. No need to run a script!

It's pretty straightforward, but it has two significant requirements - kernel-power v52 (for bridging support) and busybox-power (for the brctl bridging utility). Those are pretty unavoidable if you want to be able to do multiple PCs. In particular, kernel-power has to be v52 (or, hypothetically, any later version - there aren't any as of this writing) because that's when bridging support was added.

kernel-power v52 can be found here:
http://talk.maemo.org/showpost.php?p...&postcount=141
busybox-power can be found in extras-devel or any mirror of same.

Anyways, here's how this works:
1) Install kernel-power v52 and busybox-power.

2) Reboot so the new kernel is loaded.

3) As root, edit /etc/network/interfaces and add the following lines at the bottom:
Code:
auto pan0
iface pan0 inet static
        address 192.168.2.1
        netmask 255.255.255.0
        pre-up sh -c "/usr/sbin/iptables -t nat -F ; /usr/sbin/iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE ; echo 1 >/proc/sys/net/ipv4/ip_forward"
        up sh -c "/sbin/start-stop-daemon -S -p /var/run/btpan.pid -m -b -x /usr/sbin/dnsmasq -- -k -I lo -z -a 192.168.2.1 -F 192.168.2.100,192.168.2.105 -b"
        down sh -c "/sbin/start-stop-daemon -K -p /var/run/btpan.pid"
4) As root, create the new file /etc/udev/rules.d/50-bnep.rules with the following contents:
Code:
KERNEL=="pan0", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifup -f %k'"
KERNEL=="pan0", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifdown -f %k'"
KERNEL=="bnep0", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep0", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
KERNEL=="bnep1", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep1", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
KERNEL=="bnep2", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep2", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
KERNEL=="bnep3", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep3", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
KERNEL=="bnep4", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep4", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
KERNEL=="bnep5", ACTION=="add", RUN+="/bin/sh -c '/sbin/ifconfig %k up; /usr/bin/brctl addif pan0 %k'"
KERNEL=="bnep5", ACTION=="remove", RUN+="/bin/sh -c '/sbin/ifconfig %k down'"
And presto-changeo, you should have automatic PAN connectivity. Connect each PC, wait a few seconds after the connection is established (there's a delay before the DHCP server responds), and you should be hooked up.

One possible caveat - it's possible that you'll have to create the pan0 device somehow (normally this is done by running "brctl addbr pan0" as root). I didn't have to do this when I set this up, and I don't think anyone else would either, but it is kind of a potential isssue. You can tell if you have to or not by running "brctl show" after you've installed kernel-power v52 and busybox-power and rebooted. If it's created for you, you'll see a listing resembling this:
Code:
bridge name     bridge id               STP enabled     interfaces
pan0            8000.000000000000       no
I didn't run into this on the first try (and on the second phone, I only had to run it once and it was persistent across reboots), but it seems like it could be an issue, potentially. Hopefully not.

Hope this helps!


(Partly inspired by bits of the script in this thread, and by work done by Michael Krelin seen here: http://hacker.klever.net/n/2011/06/0...-bluetooth-pan - if you look in the comments on that blog post, you'll see me describing this method there too - and if you don't need multiple PCs and don't want to install the latest kernel-power, there's also instructions on having automatic no-need-to-run-a-script connectivity for one device there. )

Last edited by Viqsi; 2013-07-29 at 17:00. Reason: revised after work with a second phone
 

The Following 9 Users Say Thank You to Viqsi For This Useful Post: