Using GPRS/UMTS under FreeBSD

I have a Motorola E1000 3G phone, which I occationally use as a modem to get one of my FreeBSD-based laptops online from non-wifi covered locations using either a bluetooth link or an USB cable.

As it seems many people find it difficult to set up ppp(8) I decided to share my simple configuration example here – hopefully someone will find it useful.

Start by finding the bluetooth address of your mobile phone:

# hccontrol inquiry
Inquiry result, num_responses=1
Inquiry result #0
        BD_ADDR: 00:11:22:33:44:55
        Page Scan Rep. Mode: 0x1
        Page Scan Period Mode: 00
        Page Scan Mode: 00
        Class: 52:22:04
        Clock offset: 0x3485
Inquiry complete. Status: No error [00]

You can put a host entry in /etc/bluetooth/hosts – this is like /etc/hosts for bluetooth devices/commands:

00:11:22:33:44:55       MyPhone

Next, put an entry in /etc/bluetooth/hcsecd.conf and launch hcsecd using the /etc/rc.d/hcsecd rc script:

device {
        bdaddr  00:11:22:33:44:55;
        name    "My Phone";
        key     nokey;
        pin     "1234";

Replace the PIN code “1234” with something of your liking and make sure the /etc/bluetooth/hcsecd.conf is not world readable. You will need this PIN code when pairing your phone with your laptop.

Finally, you need to tell ppp(8) how to connect to your ISP. Replace the content of /etc/ppp/ppp.conf with the following:

        set log Phase Chat LCP IPCP CCP tun command

        set authname
        set authkey
        set phone "*99***1#"

        set dial "ABORT ERROR \\
                  ABORT NO\\sCARRIER \\
                  ABORT NO\\sDIALTONE \\
                  ABORT BUSY \\
                  ABORT NO\\sANSWER \\
                  TIMEOUT 5 \\
                  \"\" ATZ \\
                  OK-AT-OK ATE1 \\
                  OK-AT-OK AT+CGATT=0 \\
                  OK-AT-OK AT+CGDCONT=1,\\\\\"IP\\\\\",\\\\\"internet\\\\\",\\\\\"\\\\\",0,0 \\
                  OK-AT-OK \\\\dATD\\\\T \\
                  TIMEOUT 30 \\

        set login
        set timeout 1800
        enable dns
        resolv rewrite

        set ifaddr
        add default HISADDR

        load dialup
        enable force-scripts

        load dialup
        set device /dev/ttyU0
        set speed 460800

The above assumes that your phone appears as /dev/ttyU0 when plugged in using the USB cable. If you only intend to use bluetooth you can skip the “ucom” section all together.

Make sure to replace the string “internet” in the above with the APN (Acces Point Name) given to you by your ISP. The above works for connections made through the Danish ISPs Telmore and TDC Mobil.

Now it should be as simple as running rfcomm_pppd -d -a phone -C DUN -l rfcomm and presto (or maybe not presto, it takes a few seconds to establish the connection) – you’re online using GPRS/UMTS. You can replace “-C DUN” with the correct channel for the Dial-Up Networking service on your phone (the channel number can be found using sdpcontrol -a MyPhone browse) and save a Service Discovery Protocol lookup, if you want.

Should you instead wish to connect using the USB cable you just run ppp -foreground ucom, simple as that.

When you’re done using the connection you can just Ctrl+C rfcomm_pppd(8) or ppp(8) and the connection will be dropped.

One thought on “Using GPRS/UMTS under FreeBSD”

Leave a Reply

Your email address will not be published. Required fields are marked *