Bluetooth PAN

(added internet connection sharing for n900)
Line 20: Line 20:
To connect to the Internet through this connection you must make sure the "Internet Connection Sharing" application is running on your phone and has a connection. Select the "Dummy Network" from the tablet network list and enjoy anywhere Internet!
To connect to the Internet through this connection you must make sure the "Internet Connection Sharing" application is running on your phone and has a connection. Select the "Dummy Network" from the tablet network list and enjoy anywhere Internet!
 +
 +
==Sharing your connection over bluetooth [n900][WIP]==
 +
 +
Using udev to automatically setup internet connection sharing over bluetooth
 +
 +
A kernel with iptables support is needed, CSSU has a suitable kernel by default stock fremantle does not
 +
 +
Install the ''iptables'' package:
 +
apt-get install iptables
 +
 +
create the following 2 files:
 +
 +
/etc/udev/rules.d/98-bnep0.rules:
 +
ACTION=="add", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"
 +
ACTION=="remove", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"
 +
 +
/etc/udev/bluenet.sh:
 +
#! /bin/sh
 +
if [ $ACTION = "add" ]; then
 +
echo 1 > /proc/sys/net/ipv4/ip_forward
 +
iptables -t nat -A POSTROUTING ! -o lo -j MASQUERADE
 +
ifconfig bnep0 192.168.3.1
 +
ifconfig bnep0 up
 +
/usr/sbin/dnsmasq -I lo -z -a 192.168.3.1 -F 192.168.3.64,192.168.3.127 -x /var/run/dnsmasq.pid.bnep0
 +
else
 +
iptables -t nat -D POSTROUTING ! -o lo -j MASQUERADE
 +
if [ -f /var/run/dnsmasq.pid.bnep0 ]; then
 +
DNSMASQ_PID=`cat /var/run/dnsmasq.pid.bnep0`
 +
rm -f /var/run/dnsmasq.pid.bnep0
 +
kill $DNSMASQ_PID
 +
        fi
 +
fi
 +
then set ''/etc/udev/bluenet.sh'' as executible:
 +
chmod +x /etc/udev/bluenet.sh
 +
 +
now whenever an authorised remote device makes a bluetooth pan (nap) connection iptables and dnsmasq are setup to allow that device access to the phones network
 +
TODO: when no internet connection is active ask to set it up
 +
=== Using PAN on older releases ===
=== Using PAN on older releases ===

Revision as of 03:42, 26 March 2014

This allows you to use your Maemo device to use Bluetooth PAN to connect via another device to another network such as the Internet.

The Connection manager is used for this purpose, exactly the same way as you connect to a WLAN network or to a cell phone dial-up connection (Bluetooth DUN). Most Windows Smartphones use this method of connection when used as a modem via Bluetooth.

If you have Nokia N900 you may instead use it as PAN server to allow an other device such as a Nokia N8x0 to utilize Bluetooth PAN.

Installing

For the Nokia N900 pan is disabled by default. To enable it, edit /etc/bluetooth/main.conf and remove network from the disabled plugins

[General]
# List of plugins that should not be loaded on bluetoothd startup
DisablePlugins = network,input,hal

libicd-network-null is also recommended for using internet over bluetooth

apt-get install libicd-network-null

For other devices you need to install maemo-pan through the Application manager. You may need to restart your tablet after installation in order to force a dependency on maemo-pan (libicd-network-dummy package) being loaded.

Tap on the Connectivity icon in your status bar and either "Select a connection" or "Change connection" to see a list of available network access points. You should see one called "Dummy Network" (this name will likely change in future versions of maemo-pan, see bug #3306 for details).

To connect to the Internet through this connection you must make sure the "Internet Connection Sharing" application is running on your phone and has a connection. Select the "Dummy Network" from the tablet network list and enjoy anywhere Internet!

Sharing your connection over bluetooth [n900][WIP]

Using udev to automatically setup internet connection sharing over bluetooth

A kernel with iptables support is needed, CSSU has a suitable kernel by default stock fremantle does not

Install the iptables package:

apt-get install iptables

create the following 2 files:

/etc/udev/rules.d/98-bnep0.rules:

ACTION=="add", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"
ACTION=="remove", SUBSYSTEM=="net",  KERNEL=="bnep0", RUN+="/etc/udev/bluenet.sh"

/etc/udev/bluenet.sh:

#! /bin/sh
if [ $ACTION = "add" ]; then 
	echo 1 > /proc/sys/net/ipv4/ip_forward
	iptables -t nat -A POSTROUTING ! -o lo -j MASQUERADE
	ifconfig bnep0 192.168.3.1
	ifconfig bnep0 up
	/usr/sbin/dnsmasq -I lo -z -a 192.168.3.1 -F 192.168.3.64,192.168.3.127 -x /var/run/dnsmasq.pid.bnep0
else
	iptables -t nat -D POSTROUTING ! -o lo -j MASQUERADE
	if [ -f /var/run/dnsmasq.pid.bnep0 ]; then
		DNSMASQ_PID=`cat /var/run/dnsmasq.pid.bnep0`
		rm -f /var/run/dnsmasq.pid.bnep0
		kill $DNSMASQ_PID
       fi
fi

then set /etc/udev/bluenet.sh as executible:

chmod +x /etc/udev/bluenet.sh

now whenever an authorised remote device makes a bluetooth pan (nap) connection iptables and dnsmasq are setup to allow that device access to the phones network TODO: when no internet connection is active ask to set it up


Using PAN on older releases

It is possible to use PAN to share Internet connections via PAN between two Nokia devices. However, on older devices it is recommended to use Bluetooth DUN (dial-up networking), since this is the normal method which smartphones use to share Internet access over Bluetooth.