Thursday, 1 August 2013

Installing and Configuring 3G DataCard on CentOS


Installation steps mentioned in the Documentation are tested on CentOS 6

Follow the steps mentioned in the following order.

1) Install CentOS 6.3.

2) Following are the prerequisite package for connecting 3G USB Dongle
   wvdial
   usb_modeswitch-data
   usb_modeswitch
You can download the above package from following site on your Pen Drive or other media.
   http://mirror.centos.org/centos/6/os/x86_64/Packages/wvdial
   http://pkgs.repoforge.org/usb_modeswitch-data
   http://pkgs.repoforge.org/usb_modeswitch
3) Connect the USB 3G Dongle on the system and check the device is detected using lsusb command or in /var/log/messages.
   lsusb
   Bus 001 Device 003: ID 12d1:140c Huawei Technologies Co., Ltd.
OR
   tail -f /var/log/messages

   Aug 1 11:09:04 localhost kernel: usb 1-7: Product: HUAWEI Mobile
   Aug 1 11:09:04 localhost kernel: usb 1-7: Manufacturer: HUAWEI Technology
4) Check the device type by which modem is connected using dmesg.
   dmesg | grep tty

   usb 1-8: GSM modem (1-port) converter now attached to ttyUSB0
   usb 1-8: GSM modem (1-port) converter now attached to ttyUSB1
   usb 1-8: GSM modem (1-port) converter now attached to ttyUSB2
   usb 1-8: GSM modem (1-port) converter now attached to ttyUSB3
5) Once USB is connected and detected, now is the time to configure wvdial.
   vi /etc/wvdial.conf 
   [Dialer Defaults]
   Init1 = ATZ
   Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
   Init3 = AT+CGDCONT=1,"IP","airtelgprs.com"
   stupid mode = 1
   Modem Type = USB Modem
   Baud = 460800
   New PPPD = yes
   Modem = /dev/ttyUSB0
   ISDN = 0
   Phone = *99#
   Carrier Check = no
   Password = airtel
   Username = airtel
   FlowControl=Hardware(CRTSCTS)
6) Once we have prepared the config file now is the time to connect wvdial.
   wvdial
   --> WvDial: Internet dialer version 1.60
   --> Cannot get information for serial port.
   --> Initializing modem.
   --> Sending: ATZ
   OK
   --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
   ATQ0 V1 E1 S0=0 &C1 &D2
   OK
   --> Sending: AT+CGDCONT=1,"IP","airtelgprs.com"
   AT+CGDCONT=1,"IP","airtelgprs.com"
   OK
   --> Modem initialized.
   --> Sending: ATDT*99#
   --> Waiting for carrier.
   ATDT*99#
   CONNECT
   --> Carrier detected.  Starting PPP immediately.
   --> Starting pppd at Mon Aug  5 18:55:58 2013
   --> Pid of pppd: 3070
   --> Using interface ppp0
   --> pppd: ?
   --> pppd: ?
   --> pppd: ?
   --> pppd: ?
   --> pppd: ?
   --> local  IP address 223.228.201.19
   --> pppd: ?
   --> remote IP address 10.64.64.64
   --> pppd: ?
   --> primary   DNS address 125.22.47.102
   --> pppd: ?
   --> secondary DNS address 125.22.47.103
   --> pppd: ?
6) Check the logs (/var/log/messages) and try to make entry of Primary and Secondary DNS server in /etc/resolv.conf, if it is not updated.
   Aug 1 14:35:40 localhost pppd[3794]: pppd 2.4.5 started by root, uid 0
   Aug 1 14:35:40 localhost pppd[3794]: Using interface ppp0
   Aug 1 14:35:40 localhost pppd[3794]: Connect: ppp0 <--> /dev/ttyUSB0
   Aug 1 14:35:40 localhost pppd[3794]: CHAP authentication succeeded
   Aug 1 14:35:40 localhost pppd[3794]: CHAP authentication succeeded
   Aug 1 14:35:43 localhost pppd[3794]: Could not determine remote IP address: defaulting to 10.64.64.64
   Aug 1 14:35:43 localhost pppd[3794]: local IP address 106.200.21.246
   Aug 1 14:35:43 localhost pppd[3794]: remote IP address 10.64.64.64
   Aug 1 14:35:43 localhost pppd[3794]: primary DNS address 125.22.47.102
   Aug 1 14:35:43 localhost pppd[3794]: secondary DNS address 125.22.47.103
   Aug 1 14:35:45 localhost ntpd[2903]: Listening on interface #5 ppp0, 106.200.21.246#123 Enabled
Resolv file will look like
   vi /etc/resolv.conf 
   nameserver 125.22.47.102
   nameserver 125.22.47.103
7) Congratulation now you are connected, grap a glass of bear and enjoy surfing the Net. Debugging steps *) Check device is in Storage or Modem Mode.
**) Use usb-devices or lsusb command to check.
   usb-devices
   T: Bus=01 Lev=01 Prnt=01 Port=07 Cnt=01 Dev#= 9 Spd=480 MxCh= 0
   D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
   P: Vendor=12d1 ProdID=1446 Rev=00.00
   S: Manufacturer=HUAWEI Technology
   S: Product=HUAWEI Mobile
   C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
   I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
   I: If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
OR
   lsusb
   Bus 001 Device 003: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)
"1446" is the product id for the file mode of this dongle. (It is in Storage mode).
   lsusb
   Bus 001 Device 003: ID 12d1:140c Huawei Technologies Co., Ltd.
"140c" is the product id for the file mode of this dongle. (It is in USB mode). **) Load the usbserial kernel module using following command.
   modprobe usbserial vendor=0x12d1 product=0x140c
**) usb_modeswitch package is used to switch the USB dongle from CDROM file system to Modem mode (→ flip flop). Create the following file.
   cat /etc/usb_modeswitch.conf
   DefaultVendor= 0x12d1 
   DefaultProduct=0x1446 

   TargetVendor= 0x12d1 
   TargetProductList="1001,1406,140b,140c,141b,14ac" 

   CheckSuccess=20 MessageContent="55534243123456780000000000000011060000000000000000000000000000" 
**) Now run the following command to switch from storage to modem mode.
   usb_modeswitch -c /etc/usb_modeswitch.conf
   Check the /var/log/message it will show something like
   Aug 1 14:35:08 localhost kernel: usb 1-8: configuration #1 chosen from 1 choice
   Aug 1 14:35:08 localhost kernel: option 1-8:1.0: GSM modem (1-port) converter detected
   Aug 1 14:35:08 localhost kernel: usb 1-8: GSM modem (1-port) converter now attached to ttyUSB0
   Aug 1 14:35:08 localhost kernel: option 1-8:1.1: GSM modem (1-port) converter detected
   Aug 1 14:35:08 localhost kernel: usb 1-8: GSM modem (1-port) converter now attached to ttyUSB1
   Aug 1 14:35:08 localhost kernel: option 1-8:1.2: GSM modem (1-port) converter detected
   Aug 1 14:35:08 localhost kernel: usb 1-8: GSM modem (1-port) converter now attached to ttyUSB2
   Aug 1 14:35:08 localhost kernel: option 1-8:1.3: GSM modem (1-port) converter detected
   Aug 1 14:35:08 localhost kernel: usb 1-8: GSM modem (1-port) converter now attached to ttyUSB3
   Aug 1 14:35:08 localhost kernel: scsi23 : SCSI emulation for USB Mass Storage devices
   Aug 1 14:35:08 localhost kernel: scsi24 : SCSI emulation for USB Mass Storage devices
   Aug 1 14:35:09 localhost modem-manager: (ttyUSB0) opening serial device...
**) Now try the steps mentioned from Steps 5 onwards. *) Also try to remove any other mounted usb storage media and try the steps mentioned above once again.
   Reference for further reading
   *) https://wiki.archlinux.org/index.php/3G_and_GPRS_modems_with_pppd
   *) https://wiki.archlinux.org/index.php/USB_3G_Modem

9 comments:

  1. Hello

    Very Very Thanks sachin.

    I have followed so many documents for configuring 3g DONGLE

    Now its working fine.........

    ReplyDelete
  2. The output of dmesg | grep tty I got : [ 0.000000] console [tty0] enabled
    Also when I run sudo wvdialconf /etc/wvdial.conf, it says no modem found.
    Can you please help me out

    Thanks in advance........

    ReplyDelete
  3. Please forward me the output of step 3 & 4.

    ReplyDelete
  4. Hi.. I tried the below..

    1. Installed Redhat 6.4

    2. Installed wvdial, usb_modeswitch-data, usb_modeswitch packages

    3. # lsusb
    Bus 002 Device 005: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)

    4. # dmesg

    usb 2-1.2: new high speed USB device number 4 using ehci_hcd
    usb 2-1.2: New USB device found, idVendor=12d1, idProduct=1446
    usb 2-1.2: New USB device strings: Mfr=3, Product=2, SerialNumber=0
    usb 2-1.2: Product: HUAWEI Mobile
    usb 2-1.2: Manufacturer: HUAWEI Technology
    usb 2-1.2: configuration #1 chosen from 1 choice
    scsi8 : SCSI emulation for USB Mass Storage devices
    usb-storage: device found at 4
    usb-storage: waiting for device to settle before scanning
    scsi9 : SCSI emulation for USB Mass Storage devices
    usb-storage: device found at 4
    usb-storage: waiting for device to settle before scanning
    usb-storage: device scan complete
    scsi 9:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
    sd 9:0:0:0: Attached scsi generic sg4 type 0
    sd 9:0:0:0: [sdd] Attached SCSI removable disk
    usbcore: registered new interface driver usbserial
    USB Serial support registered for generic
    usbserial_generic 2-1.2:1.0: generic converter detected
    usb 2-1.2: generic converter now attached to ttyUSB0

    5. # vim /etc/wvdial.conf

    [Dialer Defaults]
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
    Init3 = AT+CGDCONT=1, "IP","Aircelgprs" # I'm using unlocked idea datacard and using Aircel network.
    Stupid Mode = 1
    Modem Type = USB Modem
    Baud = 460800
    New PPPD = yes
    Modem=/dev/ttyUSB0
    ISDN=0
    Phone=*99#
    Carrier Check = no
    Username = ""
    Password = ""
    FlowControl=Hardware(CRTSCTS)


    6. # wvdial

    --> WvDial: Internet dialer version 1.60
    --> Cannot get information for serial port.
    --> Initializing modem.
    --> Sending: ATZ
    --> Sending: ATQ0
    --> Re-Sending: ATZ
    --> Modem not responding.

    7. # vim /etc/resolv.conf

    nameserver 125.22.47.102
    nameserver 125.22.47.103

    8. # usb-devices

    T: Bus=02 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 4 Spd=480 MxCh= 0
    D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
    P: Vendor=12d1 ProdID=1446 Rev=00.00
    S: Manufacturer=HUAWEI Technology
    S: Product=HUAWEI Mobile
    C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
    I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usbserial_generic
    I: If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

    But still I am not able to connect to the internet. Still I'm getting the below error...

    --> WvDial: Internet dialer version 1.60
    --> Cannot get information for serial port.
    --> Initializing modem.
    --> Sending: ATZ
    --> Sending: ATQ0
    --> Re-Sending: ATZ
    --> Modem not responding

    ReplyDelete
  5. Hello , If I typed the command vim /etc/wvdial.conf I get a blank page in vim editor. what could be wrong ?

    ReplyDelete
  6. Please let me know what are the service providers that support CentOS or Red Hat!! Please post the Data card connection and the model . waiting for this from past 6 months. Thanks in advance.

    ReplyDelete
  7. Thanks for sharing useful information.

    Videocon offers one of the best postpaid prepaid service in Mumbai

    ReplyDelete
  8. hi
    I am trying to connect my AIRCELL sim in vodafone dongle
    It is working in my one sim and not working in anopther sim.
    net slution is --------- add Init3 = AT+CGDCONT=1, "IP","Aircelgprs"

    I don't know how to add.
    Please tell me.
    yogesh0405@gmail.com

    ReplyDelete