Azmawee 127.0.0.1

"Mauiwagen. Das Server." – pub 4096R/712DAA69

3G on FreeBSD, Malay and English version :D

* English version below.

FreeBSD 7.2 : 3G HSDPA Setting (with Celcom 3G).

Untuk menggunakan modem hsdpa ni, kene switch dulu antara mode "install driver" atau "Zero-CD" ke mode "modem", biasa la kan dalam windows modem ni akan install driver sendiri kan.

Kita ada 2 cara iaitu cara camcontrol+dedv dan usb_modeswitch.

Dalam howto ni aku guna cara camcontrol+devd je pasal senang sikit.
Mula2 kena prepare dulu la system kita, freebsd 7.2 dah ada u3g drive so tak perlu lagi compile apa2 cume load je driver tu dalam /boot/loader.conf
antara benda2 yang kene load adalah:

u3g_load="YES"
umass_load="YES"

Kadang2 ade yang kene load ugen, pasal lain modem lain perangai dia (ugen_load="YES"), tapi biasanye dah default ada dalam kernel GENERIC (default install).

Ok, reboot kalau nak, kalau tak nak load module tu manually.

Plug in modem anda ke usb, anda akan nampak massage akan keluar kat screen samaada umass atau ugen, so modem tu dah detech dan masuk ke mode "install driver".
Kita kene tukar mode "Zero CD" ni ke mode "modem", kalau tak tak boleh guna modem tu.

Listkan usbdevs yg ada, command usbdevs -v

[root@Server]# usbdevs -v

Cari modem anda yg mana satu, linenya lebih kurang camni:

port 1 addr 3: full speed, power 100 mA, config 1, USB MMC Storage(0x1000), Qualcomm, Incorporated(0x05c6), rev 0.00

Dalam line tu ada id intuk vendor = 0x05c6 dan product = 0x1000, rekod kat mana2 2 id tu.

Run command camcontrol devlist dan tengok yg mana satu modem anda.

[root@USB-Server]# camcontrol devlist
<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)

Dalam contoh ni modem aku adalah Option ICON. So mark line tu, kita nak ambil "pass1" saja untuk masukkan dalam conf kita seterusnya.

Create folder /etc/devd, dalam folder /etc/devd ni, create apa2 nama file, dlm contoh ni nama option.conf pasla aku guna modem vodafone option globesuffer icon.

File option.conf dalam /etc/devd/:

attach 100 {
match "device-name" "umass[0-9]+";
match "vendor" "0x05c6";
match "product" "0x1000";
match "devclass" "0x00";
action "sleep 3; /sbin/camcontrol cmd `/sbin/camcontrol devlist | /usr/bin/grep Option | /usr/bin/awk ‘{match($10, /pass[0-9]+/); print substr($10, RSTART, RLENGTH) }’` -c ’01 00 00 00 00 00’ -i 1 i1 > /dev/null";
};

Replace vendor dan product tu ikut id modem anda.

Ok, pada line action, edit dan replace section ni dengan output camcontrol devlist anda.

/usr/bin/grep Option <- tukarkan kepada output dari line camcontrol devlist tadi.

$10 <- $10 merupakan nilai yang paling akhir/last dari seluruh line tu
perkataan dalam line yang ada "pass1" tadi, kita guna "awk" utk ambik nilai tu.

Contoh:

<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)

Perkataan $1 = <Option
Perkataan $2 = ICON 
Perkataan $3 = 2.31>
Perkataan $4 = at
Perkataan $5 = scbus1
Perkataan $6 = target
Perkataan $7 = 0
Perkataan $8 = lun
Perkataan $9 = 0
Perkataan $10 = (da1,pass1)

/pass[0-9]+/ <- gantikan dengan kepada apa yg ada dalam $10 selepas ",", kalau cd1, jadi /cd[0-9]+/

Save file option.conf tadi.

Plug out modem anda dan run /etc/rc.d/devd restart untuk loadkan option.conf tadi.

[root@Server]# /etc/rc.d/devd restart
Stopping devd.
Starting devd.

Sekarang plug in semula modem anda, cara ni adalah untuk buat automated setiap kali anda plugin modem 3g anda.

Amaran awal, bende ni still buggy, so kalau tak keluar ucom0 atau apa2 selepas detached, plug out dan plug in beberapa kali.

Cara manual:
[root@USB-Server]# camcontrol devlist
<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)

[root@USB-Server]# camcontrol cmd pass1 -c "01 00 00 00 00 00" -i 1 i1
 
Kalau semua OK akan keluar message lebih kurang macam ni:

umass1: detached
ucom0: <Option N.V. Fusion UMTS Quad-GPRS, class 0/0, rev 1.10/0.01, addr 2> on uhub2
ucom0: configured 3 serial ports (U0.%d)

 
Jadi ucom0 sudah up dan /dev/cuaU0.0 akan di created (auto).
kalau guna usba, /dev/cuaU0 akan di created.
Kita akan gunakan /dev/cuaU0.0 ni dalam ppp.conf.

Sample ppp.conf untuk Celcom 3G:

# MaUi^ (Jun, 21, 2009)
# 3G (HSDPA/UTMS) /etc/ppp/ppp.conf (FreeBSD)
# File ni kene letak dalam /etc/ppp/
# Perhatian! kene ada space pada setiap line di dalam satu label (label bermula dengan ":")
# Tanda "#" di depan line menandakan ppp tidak membaca line ini (remark)
# untuk dial, taip –> ppp -ddial label (sebarang label yang ada)
default:
# setkan default gateway bila online
add! default HISADDR
# ——————————
# enablekan nat untuk sharing internet
nat enable yes
# ——————————
# enable dcc send pada client di belakang gateway
nat same_ports yes
nat use_sockets yes
# ——————————
# untuk cek connection error/link/speed : tail -f /var/log/ppp.log
set log connect phase tun connect
enable dns
# atau pakai dns server lain
# set dns 127.0.0.1
# ——————————
# 3G Celcom.
# kalau guna ubsa, ucom0 = cuaU0
# kalau guna u3g, ucom0 = cuaU0.0
3g:
set device /dev/cuaU0.0
set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \"\" ATZ OK-ATZ-OK AT+CGDCONT=1,\\\"IP\\\",\\\"celcom3g\\\" OK \\dATD\\T TIMEOUT 40 CONNECT"
# dial number adalah *99# atau *99***1
set phone "*99***1#"
set authname ""
set authkey ""
set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
enable lqr
disable ipv6cp

Sekian.

###############################################################

3G HSDPA/UMTS usb modem/card or 3G capable Phone.
FreeBSD 7.2-RELEASE
MaUi^/Azmawee
azmawee@yahoo.com

General Information
———————–
First of all, almost all of 3G modem in the market have a "Zero-CD" mode, that will automaticaly install a driver when plug in to windows based os, so by default when we plug it in to our freebsd system, it will go to "Zero-CD" mode. We need to change this mode to a "Modem" mode in order to use it in our freebsd system.

There are two ways to do this, either using camcontrol+devd or usb_modeswitch. I use camcontrol+devd method as by default it already in the system.

So, while listening to your 8 GB china brand mp3 player or your Apple iphone or ipod, or some of you that have a super duper high output amp stereo hifi with a very big speaker that can blow out your entire neighborhood house, lets get started!

Requirements
—————–
Server/PC/Laptop with FreeBSD 7.2 with u3g module loaded.
3G HSDPA/UMTS usb/card  or 3G capable phone that supported by FreeBSD/u3g.
Apple iPod/iPhone(trademark to Apple Inc) or a China brand (or no-brand) mp3 player. – This is optional.
Working 3G internet access.
This Guide (duhhh…).

Configuration
—————————
Freebsd 7.2 has include u3g driver in it, so we are going to use that driver, load up the driver in /boot/loader.conf or compile it into the kernel, so ask your wife or your house cleaning maid for a choice :). My modem detected as umass0, some of the modem detected as ugen0 so load which that are detected.

u3g_load="YES"
umass_load="YES"

Then reboot if you want or load it up using kldstat.
Plugin you modem to your system and use usbdevs command to see your modem details, you will need to search which one of the lines are your modem belongs.

[root@Server]# usbdevs -v

mine was :

port 1 addr 3: full speed, power 100 mA, config 1, USB MMC Storage(0x1000), Qualcomm, Incorporated(0x05c6), rev 0.00

In this line, we need to get the id for vendor and product, so mine was  vendor = 0x05c6 and product = 0x1000.

Next use camcontrol devlist command.

[root@USB-Server]# camcontrol devlist
<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)

So my modem detected as Option ICON 2.31, in the last part of the line was (da1,pass1), we need to use the "Option" and "pass1" value.
Create a folder in /etc namd devd, /etc/devd, in this folder create any file name, I’m using option.conf same with my modem, vodafone option globesuffer icon.

In the option.conf file, put this:

attach 100 {
match "device-name" "umass[0-9]+";
match "vendor" "0x05c6";
match "product" "0x1000";
match "devclass" "0x00";
action "sleep 3; /sbin/camcontrol cmd `/sbin/camcontrol devlist | /usr/bin/grep Option | /usr/bin/awk ‘{match($10, /pass[0-9]+/); print substr($10, RSTART, RLENGTH) }’` -c ’01 00 00 00 00 00’ -i 1 i1 > /dev/null";
};

Next, be warn, some of you might be needing master yoda training to help you on this :) just kidding.. move on..
Replace vendor and product with the id or your modem.
In the action line, you will need to edit a few things:-

/usr/bin/grep Option <- replace with the output of your camcontrol devlist before, mine was Option.

$10 <- $10 is the value of the 10th result from the camconrol devlist line, mine has pass1 value remember?

example:
<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)
$1 = <Option
$2 = ICON 
$3 = 2.31>
$4 = at
$5 = scbus1
$6 = target
$7 = 0
$8 = lun
$9 = 0
$10 = (da1,pass1)

/pass[0-9]+/ <- replace with your camcontrol devlist last value, if it was cd1 then it will be /cd[0-9]+/

Save the option.conf file.
Plug out your modem and run /etc/rd.d/devd restart to reload new conf for devd.

[root@Server]# /etc/rc.d/devd restart
Stopping devd.
Starting devd.

Now, plug back your modem and if everything fine, they will be a message like this:

umass1: detached
ucom0: <Option N.V. Fusion UMTS Quad-GPRS, class 0/0, rev 1.10/0.01, addr 2> on uhub2
ucom0: configured 3 serial ports (U0.%d)
 
This was still buggy I think, some of you might not have any message at all, try to plug in and out a few times.

You can also do manual switch without using devd:
[root@USB-Server]# camcontrol devlist
<Option ICON 2.31> at scbus1 target 0 lun 0 (da1,pass1)

[root@USB-Server]# camcontrol cmd pass1 -c "01 00 00 00 00 00" -i 1 i1

So if everything working, ucom0 already up, then /dev/cuaU0.0 will be created by u3g, if you are using ubsa, then /dev/cuaU0 will be created.
we are going to use /dev/cuaU0.0 in ppp.conf.

This is the sample of ppp.conf for Malaysia Celcom 3G ISP, you can use it as a birthday present for your wife, I dont mind :)

# MaUi^ (Jun, 21, 2009)
# 3G (HSDPA/UTMS) /etc/ppp/ppp.conf (FreeBSD)
# This file should be in put in /etc/ppp/
# IMPORTANT! every line IN A LABEL (label:) should start with a space!!
# word "#" infront of line tell ppp not to read the line
# to start dialing. run –> ppp -ddial label (or any label you add)
default:
# add default gateway when connected
add default HISADDR
# ——————————
# to enable NAT for sharing internet with other pc
  nat enable yes
# ——————————
# enable dcc send from client behind the gateway
  nat same_ports yes
  nat use_sockets yes
# ——————————
# to see connection error/link/speed : tail -f /var/log/ppp.log
  set log phase tun connect
# ——————————
# auto update with the isp nameserver in /etc/resolv.conf
enable dns
# or used other dns server
# set dns 127.0.0.1
# ——————————
# 3G Celcom.
# if using ubsa, ucom0 = cuaU0
# if using u3g, ucom0 = cuaU0.0
3g:
set device /dev/cuaU0.0
set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \"\" ATZ OK-ATZ-OK AT+CGDCONT=1,\\\"IP\\\",\\\"celcom3g\\\" OK \\dATD\\T TIMEOUT 40 CONNECT"
# dial number are *99# or *99***1
set phone "*99***1#"
set authname ""
set authkey ""
set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
enable lqr
disable ipv6cp
 
Thats all, enjoy taking over the world.. erkk I mean surfing the world wide web. :)

# End.

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz
MaUi^ - pub 4096R/712DAA69
Fingerprint 8BF7 D0AF CA45 5313 A3BF ACFB B90B 66C7 712D AA69

0110010101100001011100110111010001100101011100100010000001100101011001110110011100100000011011100110111100101110001000000011000000110110