Q&A: Connecting a Nokia 6600 to a TCP/IP Network via a Linux "gateway" using Bluetooth

Keywords:

Introduction

Some extremely helpful guides have been created to explain the "tricky" task of connecting a Symbian OS phone to the internet via a bluetooth link.

I have found, however, that none of them have completely worked for me. It has taken days to sort out problems, some of which were technical and others related to misunderstanding on my part.

I have tried to approach the topic in a Q&A format rather than providing a "recipe" because the other guides are "recipes" and I want to complement rather than replace them.

For those with phones other than the Nokia 6600 this guide can still be of use but I don't like issuing advice about a phone unless I have tried on that phone myself. There are non-obvious problems e.g. the 6630 mysteriously lacks certain libraries, causing current techniques for TCP/IP over bluetooth to fail. A good place to find out about phone support is xan's homepage.

The Linux side of this could still be helpful whatever device you are using. For people using a linux other than FC3, you may still find that everthing is ok if you have the same versions of the kernel and bluez utilities.

I can't claim that this Q&A is comprehensive or that it will work perfectly for everyone but I think that it does add something to the "armoury." I am most grateful for constructive criticism, for suggestions about how to improve the article and for questions which I will answer if I can.


Question: What other information is out there about TCP/IP over Bluetooth?

  1. Connecting Nokia 6600 and Linux over Bluetooth HOWTO
  2. Symbian Programming - Bluetooth WAP/Sync/Internet

Question: How does TCP/IP work over bluetooth?

As far as I am aware the current method for communication over bluetooth involves creating a "RF serial connection" between the pc and the phone over which a the Point-to-Point Protocol (PPP) is run.

The Phone Initiates the Connection There seem to be two ways to startup TCP/IP connections:
-  PC Initiated - where the pc sends a small message to the phone in order to provoke the phone into making a connection
-  "Phone Initiated" - a user of the phone attempts to access a web page or other net resource through a "dial up" connection and this starts the connection.

I have not managed to get the "PC initiated" method to work with linux yet so I am going to describe the "Phone Initiated" connection.

The phone has a communications database that lists all the ways of connecting to the internet (I'm simplifying a bit). You need to create an "entry" in this database for the bluetooth connection to your PC. Unfortunately the GUI that allows this entry to be changed is not sophisticated enough to cope with bluetooth connections so you have to create a "dummy" connection called "Bt" and then use a program called Gnubox to make the final settings. Gnubox will try to "scan" for your PC and allow you to "pair" with it i.e. you type in a PIN (a kind of numeric password) which allows you to access the PC from the phone.

The remaining problems are all to do with the PC. The PC must be running a Dialup Networking Daemon (dund) and must be set to advertise that it offers DUN and SP (serial port) capabilities. dund must be configured to launch the Point-to-Point Protocol Daemon (pppd) when an incoming connection from the phone is detected. A new network interface will be created (probably ppp0) which represents the connection with the phone and may then be treated like any other network interface under linux.

The Linux machine must be configured to allow "IP forwarding" so that packets from the phone can be passed by the Linux kernel from the ppp0 interface attached to the phone to whichever other interface is connected to the intenet.

Linux must also have Network Address Translation enabled for the phone if the phone is to be able to "reach" out from the Linux machine to the internet. There is no way for any internet service to know where to send replies (e.g. web pages) back to the phone since it is not using a "real" internet address so the linux machine must rewite the IP address of any outgoing packets from the phone to make them look as if they came from itself and when a reply is delivered, it must be redirected to the phone.

Question: What packages should be installed on the Phone?

Gnubox, from:

http://www.cs.helsinki.fi/u/mraento/symbian/gnubox6600.SIS

When you attempt browse the internet on a 6600 the first thing that happens is that you are asked which internet access point you wish to use. This allows you to use your GPRS etc connection or the "Bt" bluetooth over IP connection.

Gnubox allows you to configure an "internet access point" (IAP) called "Bt". You have to create the access point and Gnubox will put the correct settings into it. The gnubox6600 website has reasonable instructions for this.

One tip that I this might help is to set the IAP as follows:

  • High-speed GSM
  • no proxy
  • compression

Question: What Linux Distributions work?

I have used Fedora Core 3 with all the most recent updates as of 12 March 2005. I have self-compiled a copy of the 2.6.11 kernel, but I have made the connection work with older kernels before.

If you don't have Fedora Core 3 then you need to check that your kernel has options set like this:

CONFIG_BT_L2CAP=m
CONFIG_BT_SCO=m
CONFIG_BT_RFCOMM=m
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=m
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_CMTP=m
CONFIG_BT_HIDP=m
CONFIG_BT_HCIUSB=m
CONFIG_BT_HCIUSB_SCO=y
CONFIG_BT_HCIUART=m
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_BCSP=y
CONFIG_BT_HCIUART_BCSP_TXCRC=y
CONFIG_BT_HCIBCM203X=m
# CONFIG_BT_HCIBPA10X is not set
CONFIG_BT_HCIBFUSB=m
CONFIG_BT_HCIDTL1=m
CONFIG_BT_HCIBT3C=m
CONFIG_BT_HCIBLUECARD=m
CONFIG_BT_HCIBTUART=m
CONFIG_BT_HCIVHCI=m

Question: what packages and versions should be installed on Linux?

The following packages installed on the linux PC:

bluez-bluefw-1.0-6
bluez-hcidump-1.11-1
bluez-utils-2.10-2
bluez-libs-2.10-2
bluez-pin-0.23-3

Question: What 6600 Firmware versions work?

I have succeeded with a Nokia 6600 and firmware 3.42.1 which is very old so other versions *should* work too.

Question: How do I configure dund and pppd?

We need something to listen for any attempt by the phone to connect and to fire up a copy of pppd on whichever "bluetooth channel" the phone is using to contact us. dund waits for connection attempts and will start up PPPD for us be we have to tell dund what options to give to PPPD.

dund will connect pppd's standard input and output to correct channel for us so there is no need to worry about channel numbers or rfcomm device names etc (as some guides like to do). I

  1. Set /etc/sysconfig/dund to contain: _** DUNDARGS='--listen call dun'
  2. Start dund by typing /etc/init.d/dund start
  3. Configure pppd by creating the file: /etc/pppd/peers/dun _** 115200 '10.0.0.2:10.0.0.1' noauth silent local lock debug kdebug 31 ms-dns <dotted-ip-address-of-your-dns-server>

As you can see we are giving dund parameters for pppd via a file - the "call dund" option rather than putting all of pppd's parameters on the dund commandline. I don't know why but creating this file seems to work for me and trying to pass all the arguments through dund has the result that connections don't succeed.

The phone's IP address will be 10.0.0.1. You'll need to set up Network Address Translation on your linux machine to permit the phone to reach out from your PC to the internet.

The debug commands will allow you to see messages from PPPD in you /var/log/messages file and they should look like this:

dund[14152]: New connection from 00:60:57:FA:AA:A3
using channel 10
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm1
rcvd [LCP ConfReq id=0x1    ]
sent [LCP ConfReq id=0x1    ]
sent [LCP ConfAck id=0x1    ]
rcvd [LCP ConfAck id=0x1    ]
sent [CCP ConfReq id=0x1   ]
sent [IPCP ConfReq id=0x1  ]
rcvd [CCP ConfReq id=0x1 < 11 05 00 01 03>]
sent [CCP ConfRej id=0x1 < 11 05 00 01 03>]
rcvd [IPCP ConfReq id=0x1   ]
sent [IPCP ConfNak id=0x1   ]
rcvd [CCP ConfRej id=0x1   ]
sent [CCP ConfReq id=0x2]
rcvd [IPCP ConfRej id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [CCP ConfReq id=0x2 ]
sent [CCP ConfRej id=0x2 ]
rcvd [IPCP ConfReq id=0x2   ]
sent [IPCP ConfAck id=0x2   ]
rcvd [LCP ProtRej id=0x3 80 fd 01 02 00 04]
rcvd [IPCP ConfAck id=0x2 ]
local  IP address 10.0.0.2
remote IP address 10.0.0.1
Script /etc/ppp/ip-up started (pid 14178)
rcvd [CCP ConfReq id=0x4 ]
Script /etc/ppp/ip-up finished (pid 14178), status = 0x0
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [CCP ConfReq id=0x4 ]
rcvd [LCP TermReq id=0x2]
LCP terminated by peer
Script /etc/ppp/ip-down started (pid 19330)
sent [LCP TermAck id=0x2]
Script /etc/ppp/ip-down finished (pid 19330), status = 0x0
Connection terminated.
Connect time 585.0 minutes.
Sent 148 bytes, received 830 bytes.
Connect time 585.0 minutes.
Sent 148 bytes, received 830 bytes.

Question: How to I make my linux machine act as a Gateway to the internet for the phone?

Once the phone has contacted the dund on your linux machine and a ppp connection has been made you will have "connectivity" between your phone and your linux machine. Your phone, however, has to rely on the linux machine to act as a "relay" for connections to the internet or to the rest of the LAN.

If the phone sends a message to a web server it's own ip address is also sent to enable the web server to reply. The problem is that there is no way for the web server or any other computer to know that your phone has to be accessed via your linux machine. This means that they won't know where to send the response.

Solutions:

  1. One solution is to make the linux machine alter requests as they pass through from the phone so that the return addressing is to the linux machine. When the reply returns the Linux machine passes it on to the phone. This is called MASQUERADING.
  2. One might implement a routing protocol which would inform the nearest router that a new "network" "containing just the one phone" was now accessible through the linux machine. i.e.g the linux machine would act as a bridge.

I have tried (1) and made it work:

	#!/bin/bash

	/etc/init.d/bluetooth start
	/etc/init.d/dund start

	sdptool add DUN
	sdptool add SP
	echo 1 > /proc/sys/net/ipv4/ip_forward
	# NAT (Network Address Translation)
	# MASQUERADE 
	/sbin/iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
	 iptables -A FORWARD -i ppp0 -o eth0 -j ACCEPT

Question: How do I configure my phone

Problem: My phone thinks that it isn't paired with the PC but when I try to pair it always fails even when I enter the PC's correct PIN.

This could be a result of a "left over" /etc/bluetooth/link_key file which makes the PC think that it is paired already and thus refuse a new pairing attempt. Delete this file and restart the bluetooth "system" by typing /etc/init.d/bluetooth restart

Have you entered your PC's bluetooth pin into /etc/bluetooth/pin? Some examples show this file as a script but that is wrong under Fedora Core 3. It should just contain a number.


> Q&A: Connecting a Nokia 6600 to a TCP/IP Network via a Linux "

Hi! I am using gentoo and dund does not work like you've specified. With the command line arguments like other websites suggest, it does seem to work but I get an error on pppd saying Inarrpopriate ioctl() for the device. Any ideas why would it be so?

> Q&A: Connecting a Nokia 6600 to a TCP/IP Network via a Linux "

OK, I used Fedora Core 3 so it might be that the directory layout on gentoo is not the same and it also might be that you don't have /dev/rfcomm0, /dev/rfcomm1 etc (these are created on the fly by udev on Fedora when dund binds a particular bt address and channel to a serial port)

crw------- 1 tim root 216, 1 Aug 3 14:03 /dev/rfcomm1

crw------- 1 tim root 216, 2 Jul 31 16:13 /dev/rfcomm2

I need more information from you but there are some simple checks that you can do immediately:

Use lsmod to check that you have the bluetooth modules loaded.

[root@amachine]# lsmod | grep rf

rfcomm 40664 2

l2cap 27296 5 rfcomm

bluetooth 51076 7 rfcomm,l2cap,hci_usb

Check that sdpd is running too.

What commands did you try that gave you the ioctl error? You might get this error because you have applied some ppp configuration option to something that is not a bluetooth serial port. Another possibility is that you have the right port but have attempted to use a pppd option which is not applicable to a bluetooth serial port.

One way to debug this is to start dund with "strace -f -o /tmp/log dund ..." and then to observe what parameters dund sends to pppd and what configuration file pppd reads. If you do this then send me the log file.

What kernel are you running? (send the output of uname -a) What is your version of dund? (send 1st line of output from dund -h) What pppd do you have? (type pppd version and send 1st line of error message).

Cheers,

Tim