Linux HOW-TO. Connect to the internet with your bluetooth mobile phone or Huawei mdm

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
52,146
Reaction score
8,340
Location
127.0.0.1
Linux HOW-TO Using your blue tooth enabled mobile phone as a modem.​

I just had to do this again, so before I forget I made this how-to to help other Linux users connect to the Internet with their cellphone. I did this in Ubuntu, but you should be able to adapt it for other flavours. While there are GUI`s that can manage this, I find this the simplest way to manage both my HSDPA USB modem and my bluetooth cellphone.

This guide can easily be adapted for Huawei USB HSDPA/3G modems as well. Ignore Steps one and two. Just follow Step three and the USB modem instructions that follow Step three.

Please let me know if I made any mistakes or if there is an easier way to do it through command line.

Step one

The first bit is getting your laptop or PC to communicate with your phone.

If you are in Ubuntu you might want to sudo to root with the command:

Code:
sudo su

Alternatively if you don't want to do this as root, you can just type sudo in front of all the commands listed below.

First we scan for the device. All the latest versions of Ubuntu come with bluetooth support by default so you should have all the tools you need already.

To scan for devices run the command:

Code:
hcitool scan

Your results should look something like this:

root@hal-laptop:/home/hal# hcitool scan
Scanning ...
00:12:47:E2:68:94 Nokia
00:1E:A3:EF:24:1A Nokia 3500c
root@hal-laptop:/home/hal#


From that scan you should see your phones MAC address and device name are listed.

PLEASE NOTE ALL THROUGH THIS HOW-TO I WILL BE USING MY MAC ADDRESS. BE SURE TO REPLACE ALL INSTANCES OF MY MAC ADDRESS WITH YOURS.

Step two

Now that we have the device name and the MAC address we can pair your laptop with your phone with the following command:

Code:
hcitool cc  00:1E:A3:EF:24:1A

That command will connect you to your phone. The next step is to pair and authenticate the phone to the laptop, you do this with the command:

Code:
hcitool auth  00:1E:A3:EF:24:1A

With my laptop my phone would stay connected for a very short time for some reason. So I had to run the cc and auth commands very quickly after each other.

Once I ran the auth command on my system I scanned for my laptop from my phone, discovered and connected to it. A pin code was required to connect the devices.

Now that we are connected the phone to the laptop we are going to run a bluetooth service scan to get some information (that will be required a little later). We want to get the channel for the Dial Up Networking service in your cellphone.

We do this by running the command:

Code:
sdptool browse 00:1E:A3:EF:24:1A

This should bring up a whole lot of information about the bluetooth services running on your phone, but the specific entry we are looking for looks something like this:

root@hal-laptop:/home/hal# sdptool browse 00:1E:A3:EF:24:1A
Browsing 00:1E:A3:EF:24:1A ...
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



In my case the information I wanted was the channel my DUN uses. In this case its channel 1. The next step is to bind your laptops RFCOMM to your phone. This will allow you to create a PPP connection, and bind your phone to your laptop on start-up. To do this edit the following file:

Code:
nano /etc/bluetooth/rfcomm.conf

And insert this:

Code:
rfcomm0 {
        bind yes;
        device 00:1E:A3:EF:24:1A;
        channel 1;
        comment "PPP connect";
}

Now restart the bluetooth service with the command:

Code:
/etc/init.d/bluetooth restart

Step Three

The final step is to create a connection to your mobile operator (I have tested this on Vodacom and the CellC networks, it should work on MTN as well).
We need to create two more files. The PPP and Chat settings. First the chat script. Run the command :

Code:
nano /etc/chatscripts/vodacom

In this case I named the file vodacom, but you can basically call it anything you want. Paste the following settings into your vodacom chat script:

Code:
'' AT
TIMEOUT 60
OK ATE0
OK ATV1
OK 'AT+CGDCONT=1,"IP","internet"'
OK ATDT*99#
TIMEOUT 120
CONNECT ""

Save the file, then create and edit the following command:

Code:
nano /etc/ppp/peers/vodacom

And insert the following information:

Code:
# Enables connection debugging facilities. Speed 345600 Use hardware flow control (i.e. RTS/CTS) to control the flow of data on the 
# serial port.
crtscts
# Use the modem control lines.
modem
# Specifies that pppd should create a UUCP-style lock file for the serial device to ensure exclusive access to the device.
lock
# Disable protocol field compression negotiation in both the receive and the transmit direction.
nopcomp
# Disable magic number negotiation. With this option, pppd cannot detect a looped-back line. nomagic Disable Compression Control 
# Protocol (CCP) negotiation.
noccp
# Disable Van Jacobson style TCP/IP header compression in both the transmit and the receive direction.
novj
# Disable the connection-ID compression option in Van Jacobson style TCP/IP header compression.
novjccomp
# Don't detach from the controlling terminal.
updetach
# Disables the default behaviour when no local IP address is specified, which is to determine (if possible) the local IP address from 
# the hostname.
noipdefault
# This option causes pppd to create such a default route when IPCP comes up, and delete it when the link is terminated.
defaultroute replacedefaultroute connect '/usr/sbin/chat -e -f /etc/chatscripts/vodacom -v' disconnect '/usr/sbin/chat -e -f 
/etc/chatscripts/disconnect -v'
/dev/rfcomm0
#/dev/ttyUSB0
#Enable the DNSs from server
usepeerdns
#With this option, pppd will accept all control characters from the peer, including those marked in the receive asyncmap
receive-all nobsdcomp nodeflate
#persist

That should be it. You should now be ready to try connect. To connect to your mobile operator data network type the following command:

Code:
pon vodacom

For me a successful connection looks like this:

root@hal-laptop:/etc/chatscripts# pon vodacom
AT
OK
ATE0
OK

OK

OK

CONNECT
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
PAP authentication succeeded
Cannot determine ethernet address for proxy ARP
local IP address 10.130.62.114
remote IP address 10.6.6.6
primary DNS address 196.38.218.4
secondary DNS address 196.38.218.5
root@hal-laptop:/etc/chatscripts#


You are now connected!

To disconnect type the following command:

Code:
poff vodacom

Got to love that command ;)

USB Huawei Modem Step

Only follow these instructions if you are using a USB modem like the mobile Huawei modems. Basically when you plugged the Huawei modem in, Ubuntu automatically loaded the drivers . Well they were on my Ubuntu laptop.

All you have to do to connect with your USB modem is follow Step three and change the setting in

Code:
 nano /etc/ppp/peers/vodacom

From

/dev/rfcomm0
#/dev/ttyUSB0


to

Code:
#/dev/rfcomm0
/dev/ttyUSB0

So it uses the USB modem as the modem instead of the Bluetooth modem. Hope this guide helps some of you.
 
Top
Sign up to the MyBroadband newsletter
X