HOWTO-BluetoothNetworking-DUN-PPP

  1. HowTo set up bluetooth IP networking using Dial-Up Networking and PPP
    1. PAN vs. DUN-PPP
      1. How much difference is there?
  2. PC Setup
    1. Changes to /etc/bluetooth/hcid.conf
      1. NOTES
    2. Changes to /etc/default/bluetooth
    3. Create /etc/ppp/peers/dun
      1. NOTES
      2. Multiple Nokia Tablets
    4. Create /etc/ppp/peers/at-command.pl
      1. NOTES
    5. Prepare masquerading
      1. NOTES
  3. Nokia Internet Tablet Setup
    1. N770
    2. N800
      1. NOTES
  4. Using the connection

HowTo set up bluetooth IP networking using Dial-Up Networking and PPP

This document explains how to set up your PC in order to connect your Nokia Internet Tablet using Bluetooth, Dial-Up Networking and PPP.


PAN vs. DUN-PPP

A Bluetooth Personal Area Network (see HOWTO-BluetoothNetworking) gives a slightly better connection (no PPP overhead).

The advantage of DUN-PPP is not having to edit any files nor install any extra software packages on the Nokia Internet Tablet.

How much difference is there?

I am able to transfer a 2500kB file using scp from N770 to PC in 44 seconds (56.8kB/s) using DUN-PPP. The same transfer takes 40s (62.5kB/s) using PAN. This is with Bluetooth v.1.2. I get 31s (80.6kB/s) with BT v.2.0 using DUN-PPP - I haven't tested using PAN.

I use DUN-PPP to connect my N800 to my PC at my office where there is no WLAN. I don't notice a difference in browsing using DUN-PPP vs. PAN.


PC Setup

These instructions work on a PC using Debian/Etch with bluez-utils and ppp installed. Adjust as needed for other distributions.

Change or create the following files as needed. This setup need only be done once per PC.

Changes to /etc/bluetooth/hcid.conf

    autoinit yes;
    security user;
    pairing multi;

    name "Foobar";
    class 0x020108;
    iscan enable; pscan enable;
    lm accept;
    lp rswitch,hold,sniff,park;

NOTES

  • The class is interpreted as Device: Computer, Server; Service class: Networking.
  • iscan enable does not actually put your device into discoverable mode. I believe it just means that the device can be made discoverable when requested.
  • Use hciconfig hci0 piscan to make your PC discoverable when required.

Changes to /etc/default/bluetooth

DUND_ENABLED=1
DUND_OPTIONS="--auth --encrypt --secure --dialup call dun"

Create /etc/ppp/peers/dun

460800
crtscts
debug
local
noipdefault
passive
connect "/etc/ppp/peers/at-command.pl -v"
noauth
nodefaultroute
noipx
noaccomp
nobsdcomp
nodeflate
192.168.42.1:192.168.42.5
ms-dns <your.dns.ip.addr>

NOTES

  • The speed option (460800) has no effect on the PPP connection. I tried it with 1200, 2400, 57600, 115200, 460800 and got the same results in my transfer test no matter what.
  • Feel free to use some other private network instead of 192.168.42.1
  • Replace <your.dns.ip.addr> with your DNS server's IP (obviously)

Multiple Nokia Tablets

  • If you will be connecting more than one device, change:

    192.168.42.1:192.168.42.5 to

    192.168.42.1:

    You will then need to supply an IP address and DNS servers when setting up your Nokia tablet. Instructions included below.

  • This allows you to connect multiple Nokia Internet Tablets to the same PC and access them simultaneously. Without this change, the other NITs will share the same IP (192.168.42.5) and conflict with each other.

Create /etc/ppp/peers/at-command.pl

#!/usr/bin/perl
#
# Copyright (c) 2004 Henk Vergonet
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

#
# This script simulates an 'AT' modem command interface.
# Some dial-up-networking clients (pocketPC 2003 ...) will insist on sending
# AT command strings before connecting via PPP.
#
# Example ppp/peers/dun script for connecting my MDA to the network.
#  115200
#  local
#  noipdefault
#  connect "/etc/ppp/at-cmd.pl -v"
#  noauth
#  nodefaultroute
#  noipx
#  10.10.10.10:10.10.10.11
#  ms-dns 10.10.10.1
#
use strict;
use Getopt::Std;
use Sys::Syslog;
use POSIX qw(strftime);

my %opt;
getopts('hv', \%opt);

die "Fake at command parser\n\nusage:\n\t-v\tDebug messages in syslog\n"
        if $opt{h};

openlog($0, 'cons,pid', 'user') or die "openlog $!";
END {
        closelog();
}

$/ = "\r";
while(<STDIN>)
{
        syslog('debug', "got: $_") if defined $opt{v};
        $_ = uc;
        if(/^ATD/) {
                print "CONNECT\r\n";
                syslog('debug', "send: CONNECT\r") if defined $opt{v};
                exit(0);
        } elsif(/^AT/) {
                print "OK\r\n";
                syslog('debug', "send: OK\r") if defined $opt{v};
        }
}

NOTES

  • Original script printed with \r. I changed to \r\n. Otherwise this is unmodified

Prepare masquerading

Your PC needs to do Network Address Translation (NAT) to give your Nokia access to the internet. Therefore you will need to set up appropriate masquerading. There are many ways to do this. Here's one:

Create /root/masquerade.sh

#!/bin/sh

echo -e "\n\nSETTING UP SIMPLE MASQUERADING..."
EXTIF='eth0'

# You may or may not need some of these?
# /sbin/depmod -a
# /sbin/modprobe ip_tables
# /sbin/modprobe ip_conntrack
# /sbin/modprobe ip_conntrack_ftp
# /sbin/modprobe ip_conntrack_irc
# /sbin/modprobe iptable_nat
# /sbin/modprobe ip_nat_ftp
# /sbin/modprobe ip_nat_irc

# Clear any existing rules
iptables -F -t nat

echo "    Enabling IP forwarding..."
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/ip_dynaddr

# Enable SNAT (MASQUERADE) functionality on $EXTIF
iptables -t nat -A POSTROUTING -o $EXTIF -s 192.168.42.0/24 -j MASQUERADE

echo -e "    Firewall server rule loading complete\n\n"

NOTES

  • This assumes your external interface (the one with your default route to the internet) is eth0
  • This script will flush the iptables NAT table, destroying any other rules you or some other script / firewall may have put in there. You can check before using with iptables -L -n -t nat
  • You may also want a nameserver running locally if you're using your laptop to give your Nokia a connection at different places (like hotel rooms, conferences, client sites). With Debian, installing the bind package (apt-get install bind) is usually sufficient.

Nokia Internet Tablet Setup

Do these steps once.

N770

  1. Make your PC discoverable (hciconfig hci0 piscan)
  2. Goto 'Menu → Tools → Control Panel → Phone → New'

    You should see your PC. Make a pairing with it. I recommend a PIN of at least 10 characters.

    You will get a warning that you can only use the phone for Dial-Up Networking, not transferring files. Use class 0x120108 in /etc/bluetooth/hcid.conf and set up OBEX if you want file sharing, see http://www.mulliner.org/bluetooth/sobexsrv.php

  3. Goto 'Connectivity → Connections → New' in the Control Panel

    Choose 'Packet Data' → Next

    Leave Access Point and Tel# at defaults, leave user/pass blank → Next

    IF you chose not to specify the remote IP on the PC side (see above) THEN choose Advanced → IP Addresses and put in an appropriate IP and DNS servers.

N800

  1. Make your PC discoverable (hciconfig hci0 piscan)
  2. Goto 'Menu → Tools → Control Panel → Bluetooth → Devices → New'

    You should see your PC, pair up with it. I recommend using a 10-digit or greater pairing code

    I've set mine as a "Trusted Device"... I haven't tried it the other way yet

  3. Goto 'Connectivity → Connections → New' in the Control Panel

    Choose GPRS → Next

    Leave Access Point and Tel# at defaults, leave user/pass blank → Next

    IF you chose not to specify the remote IP on the PC side (see above) THEN choose Advanced → IP Addresses and put in an appropriate IP and DNS servers.

  4. Goto 'Phone' in the Control Panel

    Choose your new Device from step 2

    It is now 'selected'. If you don't do this then it won't show up in the Connection Manager.

NOTES

  • Don't try to find your PC in the 'Phone → New' dialog on the N800. It won't find it, presumably because we set the Device class as Computer,Server in hcid.conf.

    It might find it if we used a Phone,Cellular Device class (0x022204) but since we can use the 'Device → New' dialog to pair with the PC, it's irrelevant. I haven't tried this to see if it works.


Using the connection

Simply ensure that your PC's Bluetooth device is ready (plug in your USB dongle), then select the Connection Manager (globe in the status bar) and choose the entry you created.

If you're using an N800 and the PC is not in the list, it's likely you skipped step 4.