How to unlock 3G USB Dongles in Linux

kosandpol

Well-known member
  • Jun 10, 2008
    45,329
    1,492
    113
    While there are loads of software to pass the unlock code in to 3G dongles in Windows, there's no such software for linux. This doesnt mean it cant be done. Infact, there's no need for any special software for this even on windows.
    There is a very easy way to do this on linux. I unlocked a Huawei E160G Dongle that was sim locked to the 3 network using the method given below.

    first order of business, getting the unlock code for the 3G dongle.
    For Huawei dongles, this is very easily obtained using this site : http://bb5.at

    To do this, first get the IMEI code for your dongle and in a new browser window, enter the url as below :
    Code:
    http://bb5.at/huawei.php?imei=xxxxxxxxxxxxxxxxx
    replace xxxxxxxxxxxxxxxxx with your actual 15 digit IMEI code.
    this will show a page giving the unlock code like the one below :
    shell10.png

    The unlock code is the 8 digit number in the line that says :
    Code:
    Entsperren / Unlock: 65031494

    Tools you need :
    minicom - a terminal software that can communicate with the serial ports. On windows, there is Hyper terminal. This is the Linux counterpart for that.

    minicom is available in just about every linux distro there is.
    On Debian based systems (ubuntu,mint,mepis,etc.) this can be installed with :
    Code:
    sudo apt-get install minicom

    On Redhat based systems (CentOS, Fedora ):
    Code:
    sudo yum install minicom

    On Suse :
    Code:
    sudo zypper install minicom

    now, we need to know on what port the dongle is connected on. to do this, open up a command terminal and login as root

    Code:
    sudo su

    and run for Debian based systems :
    Code:
    tail  -f  /var/log/syslog

    For Redhat/Suse based systems :
    Code:
    tail -f /var/log/messages

    keep that terminal open and plugin the 3G dongle with the SIM removed from it.
    THere'll me a lot of lines as the kernel detects the attached device. Among them will be lines similar to these :
    Code:
    kernel: [122067.688806] usb 1-4: Product: HUAWEI Mobile
    kernel: [122067.688821] usb 1-4: Manufacturer: HUAWEI Technology
    kernel: [122067.689178] usb 1-4: configuration #1 chosen from 1 choice
    kernel: [122067.708406] option 1-4:1.0: GSM modem (1-port) converter detected
    kernel: [122067.708774] usb 1-4: [B]GSM modem (1-port) converter now attached to ttyUSB0[/B]
    kernel: [122067.709341] option 1-4:1.1: GSM modem (1-port) converter detected
    kernel: [122067.709721] usb 1-4: GSM modem [B](1-port) converter now attached to ttyUSB1[/B]
    It identified the device as a modem and attached it to the ports ttyUSB0 and ttyUSB1
    The full paths are :
    /dev/ttyUSB0 and /dev/ttyUSB1

    These are the details we need.

    we can get back to the interactive command line by pressing CTRL + C
    now, we need to configure minicom so that it'll talk to the 3G dongle. in 99% of the cases, /dev/ttyUSB0 is the port we need to unlock the dongle.

    So as root, run :
    Code:
    minicom -s

    This opens up minicom in the configuration mode.
    shell01.png

    First thing to do is to set the Serial Port so select Serial Port Config from the list of options and press Enter.
    shell02.png


    First thing is to change the port to /dev/ttyUSB0. So press A and change the /dev/tty0 to /dev/ttyUSB0
    shell03.png

    And press Enter.

    Next, we need to change the Baud Rate, paritiy and bits to 9600,N,8 (respectively). To do this, press E.
    shell04.png

    From the list of options C has 9600, so press C
    Press Enter to confirm.

    now it should look like this :
    shell05.png

    A - Serial Device : /dev/ttyUSB0
    E - Bps/Par/Bits : 9600 8N1


    Press Enter to complete the Serial port Setup.
    Now select Exit to exit the configuration menu.
    shell06.png

    Note, this is Exit and NOT Exit from minicom option.

    Now it'll initialize the modem:
    shell07.png


    And open up the terminal :
    shell08.png


    Now comes the actual command to unlock the dongle. The terminal you're in now is not a interactive shell like the usual command prompt. You cannot make any mistakes in typing commands here.
    the AT command to unlock the dongle has to be entered in capital letters so its a good idea to press capslock.

    the unlock command is :
    Code:
    AT^CARDLOCK="xxxxxxx"
    replace xxxxxxx with the unlock code for your dongle the "" are compulsory!

    shell09.png

    and press enter.

    Now, depending on the dongle model, you might get a reply like this :
    Code:
    ^CARDLOCK 2,10,0
    or simply (this is what I got for the E160G) :
    Code:
    OK

    now just close the command line interface and pull out the dongle.
    Put your own sim in and plug it in. It'll now work with your sim.

    Big thanks goes to Sandeepa for his blog post for providing the AT command to unlock, the Baud rates, and an easy way to get the unlock codes. His blog post shows how to unlock 3G dongles in windows without using any 3rd part software.

    Also credit is due to this blog post from linuxwave for giving a heads up on minicom.
     
    Last edited:

    blackhole

    Member
    Jul 3, 2007
    606
    4
    0
    47
    In a Blackhole
    yeah, its just one AT command. Wonder why these ISPs even bother to lock these things in the first place.

    Simple answer is they don't know much about Linux. :no::no::no:

    When I purchase a Dialog Huawei 1550, they said it's not support for Linux and there is no any version of Mobile partner for Linux. :baffled::baffled:

    But i'm using it without any additional software in Linux.
    :):P:):P:):P