Internet Access via Bluetooth on Linux

Setting up Internet access over Bluetooth is very easy with newer Linux distros. In fact, Fedora Core can to do it "out-of-the-box" (after you install BlueZ with something like "yum install bluez*" as root). For other distributions, you may need to download and install BlueZ first, and you will most likely need to update your Kernel as well (see the BlueZ documentation for details).

An often overlooked requirement for this procedure to work is the PPP (Point-to-Point Protocol) daemon. On RedHat-based distributions, you need the "ppp" package in order to get this functionality. The standard RedHat/Fedora Core ppp package works without modification. If you're using another distro, make sure that your /etc/ppp/options file contains no options other than "lock".

If you are using Fedora Core, however, setting up Bluetooth is as easy as doing the following:

On the server, as root:

  1. edit the file /etc/bluetooth/pin. In it, put your Bluetooth passcode (aka PIN). You'll need to enter this on your Palm when you pair it to the dongle
  2. load the hci_usb module: modprobe hci_usb
  3. initialize the device corresponding to your Bluetooth dongle, typically hci0: hciconfig hci0 up (you can confirm that the device has been set up correctly by issuing the command hciconfig -a: if all is well, the BD Address will be set to something other than 00:00:00:00:00:00, and other information about your dongle will be displayed.
  4. run the Bluetooth HCI daemon: /sbin/hcid (the exact path may be different on your distribution)
  5. run the Bluetooth Service Discovery daemon: /usr/sbin/sdpd (the exact path may be different on your distribution)
  6. load the rfcomm module: modprobe rfcomm (see the note below marked by [*])
  7. start the dial-up networking daemon: dund --listen --msdun --channel 1 192.168.2.101:192.168.2.102
  8. Issue the following commands to correctly set up IP forwarding:

    echo '1' > /proc/sys/net/ipv4/ip_forward
    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

    Make sure to replace eth0 with the device name of your Internet-connected interface on the server, and ppp0 with the PPP interface assigned to your Bluetooth connection (you can check that by issuing an ifconfig command after you've made a connection).
  9. if you wish to halt the Bluetooth network, send a kill to the dund, sdpd, and hcid processes.

On the Palm:

  1. Pair the Palm to the Bluetooth dongle: 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 one you entered in server step 1, above.
  2. In Connection Preferences, create a new connection with the following attributes: Connect To: PC, Via: Bluetooth, Device: {the name of your dongle, selected in step 1}. 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 192.168.2.101 -- 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.
  5. That should be it!

Troubleshooting

If you run into problems, the first thing to check (it should always be the first thing you check whenever you're having mysterious problems with Linux) is the contents of /var/log/messages. In this case, when you're making a connection, you should see something along the lines of:

Jul 24 23:34:39 ripley hcid[2034]: link_key_request (sba=00:03:0A:04:61:2B, dba=00:07:E0:2E:85:B7)
Jul 24 23:34:41 ripley dund[19760]: New connection from 00:07:E0:2E:85:B7
Jul 24 23:34:41 ripley pppd[19797]: pppd 2.4.2 started by root, uid 0
Jul 24 23:34:41 ripley pppd[19797]: Using interface ppp0
Jul 24 23:34:41 ripley pppd[19797]: Connect: ppp0 <--> /dev/rfcomm0
Jul 24 23:34:44 ripley pppd[19797]: local  IP address 192.168.2.101
Jul 24 23:34:44 ripley pppd[19797]: remote IP address 192.168.2.102

If you don't see those lines, what you do see should help point to where the problem lies (e.g., if the pppd lines aren't there, chances are that you don't have ppp installed, or there's a configuration problem there). When asking for help on a mailinglist or website, posting the relevant portions of /var/log/messages is a good way to solicit helpful responses.

[*] You may need to set up the rfcommx device(s) if they don't exist yet in your /dev directory. To do so, issue the command mknod /dev/rfcomm0 c 216 0 (this will make /dev/rfcomm0 -- repeat it for 1, 2, 3 by changing both the name and the minor number accordingly -- you might try this Perl script).

Return to Index

Source: Ben Steeves

(51156)

Help support this site!