<-- Back -- Feedback

PPP over Bluetooth under OS X

Brutoof
Introduction
Server Setup (GUI)
Server Setup (console)
Client Setup (Palm)
Server & Client Connection
Notes on Linux
Conclusion

Introduction

This guide is for getting PPP network connectivity over Bluetooth under Mac OS X. The reason being for this guide is that there seems to be no clear and concise instructions for doing such a thing.

Initially, I had planned on using Linux to provide the PPP over Bluetooth service, however getting a working Bluetooth stack working is, at the moment, nothing more than a headache. Apparently the bluez stack worked fairly well under version 3.x, with a plethora of documentation available, however apparently the developer(s) for bluez decided to do a total code overhaul with version 4.x. Now, this normally would be a good thing, by any means, but in doing so they decided to remove _all_ wiki documentation and provide only a few meager scraps of documentation in the source. Furthermore, there is little to no commentary in the actual sourcecode itself - the sign of, as another fellow quipped, cowboy coders.
From yet another aspect, the problem with the bluez 4.x stack is that it is dependant on libraries/systems that are good(dbus), however I do not wish to have to use such a complex program communications system when my purpose is just to simply provide PPP over Bluetooth. At any rate, I digress - let us move onto the point of this article.

Server Setup (GUI)

The first option for the PPP server is to use a relatively simple GUI I made for OS X. It ultimately does the same commands that are done in the console section, just with a graphical wrapper. It can be downloaded at Apps: Excellent Peer-to-Peer Daemon.

When you first run EPPPD, it should find all the required information, such as the TTY device, subnet, and DNS - if it somehow does not, the methods for acquiring such information is also covered in the console section. The final settings should roughly resemble the following:

EPPPD

Remember to check IP Forwarding, as that is required if you want your PPP client to be able to access machines other than the server/host. Further information is located in the Help menu item, as well as through the "?" button in the main dialog.

Server Setup (console)

To set up the service we will be using the pppd daemon. The command we will be using will, with some minor editing, be the following:
/usr/sbin/pppd DEVICENAME 115200 \
 :TARGETIP noauth local ms-dns YOURDNS passive proxyarp \
 asyncmap 0 silent debug -detach
Before this command will work we need to replace the following: DEVICENAME, TARGETIP and YOURDNS. First of all, let us find the device - open up a Terminal and type the following 'ls' command:
Krang:~ krang$ ls /dev/tty.*
/dev/tty.Bluetooth-Modem	/dev/tty.serial1
/dev/tty.Bluetooth-PDA-Sync
Krang:~ krang$ 
The replacement for DEVICENAME we want should be called /dev/tty.Bluetooth-PDA-Sync.

Next will be the IP address that will be assigned to the Bluetooth device. For this example the device will be able to access devices within the LAN as well as the internet(one can set up a private subnet between the device and the server, however that is far more complex). If you do not know your IP subnet, enter 'ifconfig' into the Terminal:
Krang:~ krang$ ifconfig
en0: flags=8863 mtu 1500
	inet6 fe80::227:eff:fe04:3451%en0 prefixlen 64 scopeid 0x4 
	inet 192.168.180.115 netmask 0xffffff00 broadcast 192.168.180.255
	ether 00:27:0e:04:34:51 
	media: autoselect (100baseTX ) status: active
	supported media: 10baseT/UTP  10baseT/UTP  100baseTX  100baseTX  1000baseT  1000baseT  autoselect
Please note that your ethernet device may not be en0(it could be en1, or any other possibility, depending on your setup), however on a ground-based LAN, it should be en0. From this information we can see that the subnet is 192.168.180.xxx(as derived from the inet line). Thus, our replacement for TARGETIP will be 192.168.180.5 (it could be any other address you want if in the same subnet).

Next will be the replacement for YOURDNS. Generally speaking, the DNS information is usually handled by your router, however if you do not know what it is, the following 'cat' command should get the information you need:
vger:~ $ cat /etc/resolv.conf
nameserver 69.59.192.61
nameserver 192.168.180.251
In this example, the DNS could be either of the two, however I will just select the one within the same subnet(it is the router) - so the replacement for YOURDNS would be 192.168.180.251 .

We now have all the information required for running the PPP daemon - however, before we can start the daemon and have a successful connection beyond just the device and the server, we must issue the following command to enable IP forwarding(login as the 'root' user with su prior to issuing this command):
sh-3.2# sysctl -w net.inet.ip.forwarding=1
net.inet.ip.forwarding: 0 -> 1
Now that everything is set up as it should be, the PPP server can be started with the following:
sh-3.2# /usr/sbin/pppd /dev/tty.Bluetooth-PDA-Sync 115200 \
 :192.168.180.5 noauth local ms-dns 192.168.180.251 passive proxyarp \
 asyncmap 0 silent debug -detach
Fri Jan 21 21:38:49 2011 : set_up_tty, can't set controlling terminal: Operation not permitted
Fri Jan 21 21:38:49 2011 : using link 0
Fri Jan 21 21:38:49 2011 : Using interface ppp0
Fri Jan 21 21:38:49 2011 : Connect: ppp0 <--> /dev/tty.Bluetooth-PDA-Sync

Client Setup (Palm)

First off, go to Preferences->Network on your Palm, then select the Unix Service(others will work too), then under Connection, go to "Edit Connections...":


Create a "New..." connection, then set it up as follows, substituting "vger" for your computer's Device, then edit "Details..." as well:


Once you have saved the new Connection, select it for our Connection under Preferences->Network.


Press the Details button and set up as follows(set Script... as well):

Server & Client Connection

If you have not started the pppd daemon as of yet, start it now, then press "Connect" on your Palm device. You should get the following output for the Palm and the PPP server:
sh-3.2# /usr/sbin/pppd /dev/tty.Bluetooth-PDA-Sync 115200 \
 :192.168.180.5 noauth local ms-dns 192.168.180.251 passive proxyarp \
 asyncmap 0 silent debug -detach
Sat Jan 22 00:00:51 2011 : set_up_tty, can't set controlling terminal: Operation not permitted
Sat Jan 22 00:00:51 2011 : using link 0
Sat Jan 22 00:00:51 2011 : Using interface ppp0
Sat Jan 22 00:00:51 2011 : Connect: ppp0 <--> /dev/tty.Bluetooth-PDA-Sync
Sat Jan 22 00:01:10 2011 : ipcp: returning Configure-NAK
Sat Jan 22 00:01:10 2011 : sent [IPCP ConfNak id=0x11   ]
Sat Jan 22 00:01:10 2011 : rcvd [IPCP ConfReq id=0x12    ]
Sat Jan 22 00:01:10 2011 : ipcp: returning Configure-ACK
Sat Jan 22 00:01:10 2011 : sent [IPCP ConfAck id=0x12    ]
Sat Jan 22 00:01:10 2011 : ipcp: up
Sat Jan 22 00:01:10 2011 : found interface en0 for proxy arp
Sat Jan 22 00:01:10 2011 : local  IP address 192.168.180.115
Sat Jan 22 00:01:10 2011 : remote IP address 192.168.180.5
You should now be able to directly access the Internet and use applicatons such as upIRC, Opera Mini, or even pssh:

Notes on Linux

Theoretically, the same pppd commands should be able to be used under Linux with very minor editing - if you can get the bluetooth stack working. In my attempts I did manage to get the devices paired, but I could not get the /dev/rfcomm0 device to work(at most it worked for about 1 second, then would disconnect from the device). In the case that someone who is more knowledgable than I can get it working, the procedures I attempted to use after pairing were:
Kya:/etc/bluetooth # hcitool cc 00:60:57:6F:A5:3E
Then, after that(redundant output cut due to length):
/usr/sbin/pppd /dev/rfcomm0 115200 192.168.181.1:192.168.181.2 local ms-dns 69.59.192.61 netmask 255.255.255.0 persist passive noauth debug -detach asyncmap 0
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent [LCP ConfReq id=0x1    ]
Modem hangup
Connection terminated.
Failed to open /dev/rfcomm0: No such file or directory
What it appeared to be doing was that it was creating the rfcomm0 device, connecting through Bluetooth for an instant, then dying immediately. I spent hours trying to figure this out to no avail. I may return to it later, perhaps when the Linux bluetooth stack isn't such a convoluted mess.

Conclusion

All in all, getting PPP <-> Bluetooth working under OS X is fairly easy(and it should be just as easy to get working under Linux, if not for the bluetooth stack issues). I would have preferred to use Linux, as that is what I acquired the Bluetooth adapter for to begin with, but this worked just as well.

To note, this is also possible under Windows, however it was just an aggrivation to get working, seeing that, as is standard with GUI-oriented systems, vital troubleshooting information is kept from you. At any rate, however, the base idea would be the same under Windows, one would just need to find a suitable replacement for pppd.

0.0091509819030762 µs