Tethering a Nokia 6165i to a Compaq nc4010 using Bluetooth (Kubuntu)

This was not that hard to do – for a sysadmin and geek – but not for a general user. One of the things I like about Kubuntu is its ease of use and preconfigured and debugged desktop, but here it fails. Setting up a dialup networking connection is sorely inadequate, and is completely unintuitive. Most of this problem stems from several problems:

  • The menu structure in KNetworkManager is very obtuse and non-obvious.
  • Configurations created by kppp and by KNetworkManager (running kppp) result in two different configurations in two different locations.
  • Configuration of the ppp0: network device is not available anywhere related to networking.

A lot of this problem stems from the way KNetworkManager is set up; however, the network configuration interface should also allow for the creation of a ppp0: device.

There also seems to be no way to create a tethered link to a bluetooth device without using the command line. Not a problem for me nor for many of you, but for a general user it would be a real stumbling block. (I guess I shouldn’t be surprised; from the project page comes this bit about dial-up support: The rudimentary dial-up support gives the user the ability to connect dial-up connections configured using YaST. There is much room for improvement. As of 16/11/2007 in Opensuse 10.3, this is broken.).

Most of the directions I took from this article titled Bluetooth DUN tethering – Linux and KDE (Might work with Gnome) from PinStack.com (a support site for Blackberry users).

In this case, I will assume that you know how to pair a cell phone device with your Linux laptop; it’s fairly easy (though not completely intuitive). I’ll also assume that all of the requisite bluetooth support is available and already installed.

You’ll need to get the MAC address for the bluetooth device. This could be done any number of ways; from the command line this will do:

$ hcitool scan
Scanning ...
00:12:D1:C9:DF:5E Nokia 6165i
$

After the MAC address is found, then the next step is to find the appropriate bluetooth channel for dial-up networking. This can be done using the sdptool command:

$ sdptool browse
Inquiring ...
Browsing 00:12:D1:C9:DF:5E ...
Service Name: Dial-up networking
Service RecHandle: 0x10000
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

A lot of information spits out, but the relevant one for me was this entry. Now create the serial link that connects the “modem” to the operating system – in particular, a device /dev/rfcomm0 is created for communicating with the bluetooth modem (which is what the phone becomes). This is done thusly:

# rfcomm bind hci0 00:12:D1:C9:DF:5E 1

Once this is done, assuming the right channel was chosen, then kppp can be configured. Because of the conflict between kppp configuration and the KNetworkManager configuration, a setup step may be worth doing (as root):

# cd ~/.kde/share/config/
# rm -f kppprc
# ln -s ~me/.kde/share/config/kppprc

What this does, then, is make it so that your personal configuration for kppp is also used by root. Now kppp can be run from the command line (since it’s already open, right?) and you won’t have to go searching for the configuration in the menu tree:

$ kppp

After kppp is configured, you should be able to use your phone as a cellular modem. The configuration I used (for U.S. Cellular) worked, and has been described in these pages in the past.

Debugging a Stuck pppd Process

I mentioned previously that on my Mac Mini I am using a cellular connection for my Internet link (instead of dial-up). However, from time to time, the connection would get stuck (after dropping) in the “Disconnecting…” state in the graphical tools. There didn’t seem to be anything I could do to stop it. The system doesn’t have what I usually consider essential tools – ptrace, strace, ltrace. In any case, there is a good chance that all three could be Linux-specific commands, and this system is running Mac OS X 10.4 (Tiger).

Then I remembered gdb. Looking up the processes for pppd I found this:

$ ps auwx | grep ppp[.]*d
root 21475 0.0 0.1 28040 1204 cu. Ss+ 10:24AM 0:00.57 pppd serviceid F31F5F28-9986-489D-88F3-CFA56FF89443 controlled
$
$ sudo gdb -p 21475
Password:
GNU gdb 6.1-20040303 (Apple version gdb-384) (Mon Mar 21 00:05:26 GMT 2005)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “powerpc-apple-darwin”.
/private/var/log/21475: No such file or directory.
Attaching to process 21475.
Reading symbols for shared libraries . done
Reading symbols for shared libraries …………………………………………….. done
0x90032084 in wait4 ()
(gdb) step
Single stepping until exit from function wait4,
which has no line number information.
^C
Program received signal SIGINT, Interrupt.
0x90032088 in wait4 ()
(gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y
Detaching from process 21475 thread 0xd03.
$

This tells me that the pppd daemon is inside a wait4() function (described in the wait(2) man page). This function is waiting for a child process to complete. So then, the next step is: what is this child process that pppd is waiting on?

$ ps alwwx | grep ppp[.]*d
0 21475 42 0 31 0 552328 1228 – Ss+ cu. 0:00.57 pppd serviceid F31F5F28-9986-489D-88F3-CFA56FF89443 controlled
$ ps alwwx | grep 21475
501 25310 25201 0 31 0 8780 8 – R+ p3 0:00.00 grep 21475
0 21475 42 0 31 0 552328 1228 – Ss+ cu. 0:00.57 pppd serviceid F31F5F28-9986-489D-88F3-CFA56FF89443 controlled
0 25131 21475 0 31 0 27688 740 – S+ cu. 0:00.02 /usr/libexec/CCLEngine -m 1 -l F31F5F28-9986-489D-88F3-CFA56FF89443 -f /Library/Modem Scripts/Nokia 3G Packet RB 460 -v -E -S 5 -L 120 -I Internet Connect -i file://localhost/System/Library/Extensions/PPPSerial.ppp/Contents/Resources/NetworkConnect.icns -C Cancel
$ sudo gdb -p 25131
GNU gdb 6.1-20040303 (Apple version gdb-384) (Mon Mar 21 00:05:26 GMT 2005)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “powerpc-apple-darwin”.
/private/var/log/25131: No such file or directory.
Attaching to process 25131.
Reading symbols for shared libraries . done
Reading symbols for shared libraries …….. done
0x90001b04 in ioctl ()
(gdb) s
Single stepping until exit from function ioctl,
which has no line number information.
^C
Program received signal SIGINT, Interrupt.
0x90001b04 in ioctl ()
(gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y
Detaching from process 25131 thread 0x20b.
$

So…. the script is stuck in ioctl (described in ioctl(2)). A kill was not sufficient, but a kill -9 stopped it. After this, the graphical tools stopped reporting “Disconnecting…” and a reconnect was possible – and went cleanly.

One aside: note the first line:

grep ppp[.]*d

This matches “nothing” (as well as multiple characters) but does not match the grep command itself (which it would if the nonsense pattern were not included). Small thing, but can help especially in scripts that grep through the ps command output. Other patterns are usable here; the key is that the pattern will not match itself, will match nothing (empty string), and will not match anything which is present in the output.