Make your Arch Linux a Bluetooth Access Point

Following my earlier article about creating a Bluetooth access point with your OS, here is my quick guide how to do just that with Arch Linux. You will need two Bluetooth-enabled devices to start with, and some patience as setting up Bluetooth is problematic on all OSes (each one with its own quirks).

I am using the AIPTEK BTuoi USB-based Bluetooth dongle, which is Class I. Class I means that the device can send/receive up to 100 meters, Class II means 10 meters and Class III, 1 meter. Most integrated BT modules on laptops/PDAs are Class II, up to 10 meters, so if you want the best performance for the Access Point we will try to create here, buy a Linux-supported Class I dongle (about $35). In any case, any Class Bluetooth module will work anyway.


One-time configuration


Start by installing the BlueZ Bluetooth and other needed packages (all as root):

 pacman -S bluez-libs bluez-utils iptables ppp


Edit your /etc/bluetooth/pin file and enter some digits: 12345 (remove the “BlueZ” word, some devices only pair with numerical pins).


Edit your /etc/bluetooth/rfcomm.conf file and make it look like this instead of the default values:

rfcomm0 {
        # Automatically bind the device at startup
        bind yes;     # original: bind yes

        # Bluetooth address of the device
        # device 11:22:33:44:55:66
        # comment out the devices' MAC addresses

        # RFCOMM channel for the connection
        channel 3; # was channel 1

        # Description of the connection
        comment "Bluetooth Access Point";
}

Edit the /etc/bluetooth/hcid.conf (this is optional, but useful) and change the name line from

name "%d h%"

to something like

name "BlueZ"


Now, edit your

/etc/ppp/options

file with a text editor and change the “auth” with “noauth” (somewhere around line 25-30). Around line 15-20, add your DNS info, e.g. something like this:

ms-dns 216.148.227.62
ms-dns 204.127.202.2

(copy the IP addresses from your /etc/resolv.conf if you are not sure what to use, the above addresses won’t work for you)


The Access Point service


All the above is needed to be done once. Here is what you need to do each time you reboot the machine and you want your Access Point to be functional:


Start the bluetooth Arch script and stop it again (it seems that this script initializes some stuff that the main script below doesn’t, so just start it and stop it like this:)

/etc/rc.d/bluetooth start
/etc/rc.d/bluetooth stop


Then, run the main script:

modprobe rfcomm
modprobe hci_usb

mknod /dev/rfcomm0 c 216 0
mknod /dev/rfcomm1 c 216 1
mknod /dev/rfcomm2 c 216 2
mknod /dev/rfcomm3 c 216 3

hciconfig hci0 up
hcid
sdptool add SP
sdpd
rfcomm bind all
# first IP address is the one of the server, 
# second the one of the client; change accordingly, depending on your network
dund --listen --msdun --channel 3 10.0.0.102:10.0.0.111
echo '1' > /proc/sys/net/ipv4/ip_forward
# use a different eth0 name if your server's incoming
#internet connection is coming from a different device
#(e.g. might be sit0 or ppp1, depending how your Arch Linux is connected to the outside world).
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i ppp0 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT


You can put all of the above in a single script too, call it btlan.sh and make it executable like this:

chmod +x btlan.sh

and then put it on your /usr/sbin/.


You are all setup (and a similar procedure works for Fedora as well) Now, you need to configure your clients to use this Bluetooth Access Point-wannabe as their server. We will try connecting to the internet via this Arch Linux-based Bluetooth Access Point with a PalmOS device, another Linux machine and a Macintosh, both Bluetooth-enabled. After setting them up, your clients will be able to even have access to your main internal network (the one your Arch Linux belongs).

Macintosh: (Panther-only)


1. Pair with the Linux machine: Turn on Bluetooth on your Mac, and then Setup a Bluetooth Device from the Bluetooth preference panel. Select “other device”, select the BlueZ device, enter the 12345 pin number as requested, and create the pairing (it’s a bit hairy procedure, sometimes doesn’t work…).


2. Open the /Applications/Utiltiies/BluetoothSerialUtility and hit “new”. Give it a name (e.g. BTLan), click “show in network preferences”, and from the port type, select rs-232. From the “Select device…” button a new window will open: select the BlueZ name and then the “LAN Access Point” option. Click Select and then Ok. Make sure the On/Off switch for BTLan on the main Serial Utility window is checked. Close that window down.


3. Go to the Preferences/Network. From the “Show” combo box, select “Network port configurations” and enable the “BTLan” option. Click Apply Now.


4. From the Show combo box again, select the BTLan option. From the TCP/IP tab, select “using PPP”. You can enter some DNS numbers there if you want btw, just in case. In the Modem tab, select the “null modem 115200” from the long list and uncheck the “wait for dial tone before dialing”. Select Apply Now. Close down the Preferences.


5. Open /Applications/InternetConnect. You should be seeing the BTLan connection name there now. Select configuration and Edit Configurations. Save that default Modem Configuration. Now, hit “connect”. You should be connected on the internet now via Arch Linux’s Bluetooth routing.


Linux machine:


After starting your bluetooth services (different for each distro, usually it’s /etc/rc.d/bluetooth start or /etc/rc.d/init.d/bluetooth start) do the following:

hcitool scan
# the above will give you something like:
#       00:11:22:33:44:55       BlueZ

modprobe bnep

# use the number found above
pand -c 00:11:22:33:44:55

# this is the IP address of your Linux client, change accordingly
ifconfig bnep0 10.0.0.111 netmask 255.255.255.0

# this is the address of your Arch Access Point server, change accordingly
route add default gw 10.0.0.102

ifconfig bnep0 up

You should now be connected to the Internet. If not, advise Google. 😉

PalmOS devices: (text borrowed from here):


1. Pair the Palm to the Bluetooth Access Point Linux machine: in Bluetooth Preferences, tap “Trusted Devices”, “Add Device”, and select your dongle’s name from the list that appears. If it asks for your passphrase, use the pin you entered earlier: 12345.


2. In Connection Preferences, create a new connection with the following attributes: Connect To: PC, Via: Bluetooth, Device: {BlueZ}. Under Details, set the speed to 115,200 bps and Flow Ctl to Automatic.


3. In Network Preferences, create a new service. You can leave the User Name and Password fields blank. Select the connection you created in the previous step, then tap Details. Here, set the Primary and Secondary DNS servers to the same as your Server, and check the box for Automatic IP Address discovery.


4. Test the connection by tapping “Connect”. After a few messages, the connection should be made. Tap Menu->Options->View Log…, and scroll to the bottom. Here, you can test the connection by sending the following ping command: ping 10.0.0.102 (or whatever your BT server’s address is) — this will test the connection between your Palm and the Server (i.e., Gateway). You can then try pinging an IP on the Internet, or a DNS name. If both work from the server, they ought to work from the handheld as well.


Conclusion


You can also configure PC laptops, desktop PCs and PocketPCs to connect to your BT Access Point as long they have BT functionality (the Access Point works for up to 7 clients, that’s a Bluetooth protocol limitation).


Here’s a guide how to connect a Windows machine on a Bluetooth Access Point. It should be fairly easy for PocketPC too. BTW, if you instead want to share internet connection via a USB or serial cable with your PalmOS (instead of Bluetooth), check this article.


Phew… That was painfull, no matter what OS you are using. But it works. Leave a comment on the forum or directly email me if you have trouble.

13 Comments

  1. 2005-02-27 1:55 pm
  2. 2005-02-27 2:14 pm
  3. 2005-02-27 3:04 pm
  4. 2005-02-27 7:19 pm
  5. 2005-02-27 8:48 pm
  6. 2005-02-27 8:59 pm
  7. 2005-02-27 9:34 pm
  8. 2005-02-27 9:53 pm
  9. 2005-02-27 10:05 pm
  10. 2005-02-28 10:31 am
  11. 2005-02-28 10:36 am
  12. 2005-02-28 4:07 pm
  13. 2005-02-28 7:58 pm