Internet over Bluetooth

OpenBSD ubt(4) and pppd(8)

EDIT 2011-02-18: This no longer works for me. The kernel will panic shortly after bringing the Bluetooth interface up. This is now a known issue and will be fixed as soon as someone steps up and does the job.

Overview

These are the steps I took to gain Internet access over Bluetooth through my Nokia 6233 on OpenBSD 4.5-current. There was no way I was going to pay 75 EUR for the USB cable to my phone, which would have made this process a bit easier (see this page).

The following notes assume a properly configured phone, and keep in mind that you probably have to change a few things at your end to get this going (the chat script most likely). This is not a general HOWTO, just my notes on what I did and what worked for me.

Configuring Bluetooth

Make sure your Bluetooth device is recognized by OpenBSD:

$ dmesg | grep ubt
ubt0 at uhub4 port 1 "Micro Star International Bluetooth" rev 2.00/32.64 addr 2

Install the bluetooth-tools package. This provides tools like btconfig(8), btpin(1), rfcomm_sppd(1):

# pkg_add bluetooth-tools

Bring the Bluetooth interface up and verify that you're able to detect your phone:

# btconfig ubt0 up
$ btconfig ubt0 inquiry
  Device Discovery from device: ubt0 .... 1 response
     1: bdaddr 00:1d:e9:e5:ad:01 (phone)
      : name "Nokia 6233"
      : class: [0x5a0204] Cellular Phone <Networking> <Capturing> <Object Transfer> <Telephony>
      : page scan rep mode 0x01
      : clock offset 27997

Add the bdaddr to /etc/bluetooth/hosts so you don't have to type in the address every time you want to refer to your phone:

# echo "00:1d:e9:e5:ad:01 phone" >> /etc/bluetooth/hosts

Connecting to your phone

Start bthcid(8), generate a pin using btpin(1) and connect to your phones' Dial Up Networking (DUN) service using rfcomm_sppd(1).

# /usr/local/sbin/bthcid
$ btpin -a phone -r -l 4
PIN: 2701
$ rfcomm_sppd -d ubt0 -a phone -s DUN
rfcomm_sppd[16519]: Starting on stdio...

You should receive a question on your phone if you want to accept the connection and then type in the PIN generated above. You should now be able to communicate with your phone:

AT
OK
ATI3
Nokia 6233

OK

Now that we know this works, we can attach it to a pty:

$ rfcomm_sppd -d ubt0 -a phone -s DUN -t /dev/ttypz
$

Connecting to the world

Create a ppp interface and connect using pppd(8):

# ifconfig ppp0 create
$ pppd call netcom
$ ifconfig ppp0
ppp0: flags=8051 mtu 1500
        priority: 0
        groups: ppp
        inet 89.8.5.99 --> 10.6.6.6 netmask 0xff000000

Now check the routing table:

$ netstat -rnf inet | grep default
default            10.6.6.6           UG         0        0     -    56 ppp0

I've no idea what the name servers are supposed to be, so I just started a local one and pointed /etc/resolv.conf at it. You really should find out what the actual name servers are, though. If you dig through the man pages you might find out how to request the name servers from the provider.

We're on!

$ ping -c 4 www.google.com
PING www.l.google.com (209.85.137.104): 56 data bytes
64 bytes from 209.85.137.104: icmp_seq=0 ttl=237 time=640.756 ms
64 bytes from 209.85.137.104: icmp_seq=1 ttl=237 time=595.876 ms
64 bytes from 209.85.137.104: icmp_seq=2 ttl=237 time=619.887 ms
64 bytes from 209.85.137.104: icmp_seq=3 ttl=237 time=645.883 ms
--- www.l.google.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 595.876/625.600/645.883/19.746 ms

Peer configuration and chat script

My option file (you probably have to modify this):

$ cat /etc/ppp/peers/netcom   # you probably don't need all this poop
/dev/ttypz
115200
local
debug
#crtscts
nodetach
noipdefault
defaultroute
lock
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
noauth
connect '/usr/sbin/chat -f /etc/ppp/peers/chat/umts.netcom'

... and my chat script (you probably have to modify this one too):

$ cat /etc/ppp/peers/chat/umts.netcom
TIMEOUT	5
ECHO		ON
ABORT		'\nBUSY\r'
ABORT		'\nERROR\r'
ABORT		'\nNO ANSWER\r'
ABORT		'\nNO DIAL TONE\r'
ABORT		'\nNO DIALTONE\r'
ABORT		'\nRINGING\r\n\r\nRINGING\r'
''		\rAT
TIMEOUT	30
OK		ATD*99#
TIMEOUT	10
CONNECT	""