Skip to main content

Using USB CDMA modem to setup a home/private WiFi network

The idea here is to give a ‘how-to’ on setting up a a home WiFi network using mobile, CDMA based USB modem, hoping that bandwidth that you obtain from this service is satisfactory :-)

Hardware Requirements:
Linux PC/Notebook/Netbook
Wifi Access point connected to ethernet port of the Linux box
CDMA-1x USB Modem (Device used: Reliance M880)

Software/OS Requirements:
Linux Operating System with “usbserial” and “cdc_acm” device driver modules
“pppd”, “wvdial”, “iptables”, and “dnsmasq” applications and their dependencies installed on the System

Setup: The steps followed in setting up this CDMA based connectivity can be split into 3 steps, as follows.
  1. Configuring kernel modules for auto-loading at bootup
  2. Configuring “wvdial” application for dialup / ppp connection
  3. Initializing / starting the CDMA modem connection
  4. Setting up “iptables” for NAT forwarding
  5. Setting up “dnsmasq” for resolving DNS and as DHCP server

Configuring kernel modules for auto-loading at bootup
  1. Open a terminal and type the command, ‘sudo bash’. This will prompt you for current, logged-in user password. Enter the password to become super-user
  2. Type ‘gedit /etc/modules’ to open the file /etc/modules
  3. Add the following entries just after the comments;
    usbserial vendor=0x19d2 product=0xfffd
    cdc_acm

    Vendor and product values may change if you use different CDMA modem. The values given are for Reliance M880 modem. Please use appropriate values in that case. You may get those values from /proc/bus/usb/devices file, when the device is connected.
  4. Save and close the file
  5. Reboot the machine for automatic driver loading to happen

Configuring “wvdial” application for dialup / ppp connection
  1. Open a terminal and type the command, ‘sudo bash’. This will prompt you for current, logged-in user password. Enter the password to become super-user
  2. Type ‘gedit /etc/wvdial.conf’ to open the file /etc/wvdial.conf
  3. Replace the contents of the file /etc/wvdial.conf with the following;
    [Dialer Defaults]
    Init1 = ATZ
    Init2 = AT+CRM=1
    Modem Type = Analog Modem
    SetVolume = 0
    Baud = 115200
    New PPPD = yes
    Modem = /dev/ttyUSB0
    Carrier Check = no
    Stupid Mode = 1
    ISDN = 0
    Phone = <dialing number>
    Password = <reliance phone number>
    Username = <reliance phone number>
    Please use the appropriate value for Dialing-number, Password and Username. The dialing-number for example is, #777
  4. Save and close the file

Initializing / starting the CDMA modem connection
  1. Open a terminal and type the command, ‘sudo bash’. This will prompt you for current, logged-in user password. Enter the password to become super-user
  2. Create a backup copy of the file /etc/resolv.conf as /etc/resolv.conf.bak. Remove all the contents of the file /etc/resolv.conf
  3. Run, ‘wvdial’ to start the connection

Setting up “iptables” for NAT forwarding
  1. Open a terminal and type the command, ‘sudo bash’. This will prompt you for current, logged-in user password. Enter the password to become super-user
  2. Create/Open the file /usr/local/sbin/ppp_eth_route, by typing ‘gedit /usr/local/sbin/ppp_eth_route’ in the terminal and enter the following;
    #!/bin/bash
    
    iptables —flush
    iptables —table nat —flush
    
    iptables —delete-chain
    iptables —table nat —delete-chain
    
    # Set up IP FORWARDing and Masquerading
    iptables —table nat —append POSTROUTING —out-interface ppp0 -j MASQUERADE
    iptables —append FORWARD —in-interface eth0 -j ACCEPT
    
    echo 1 > /proc/sys/net/ipv4/ip_forward
    
  3. Save and close the file. Change its permission to 755 by typing the command; chmod 755 /usr/local/sbin/ppp_eth_route
  4. Run /usr/local/sbin/ppp_eth_route

Setting up “dnsmasq” for resolving DNS and as DHCP server
  1. Open a terminal and type the command, ‘sudo bash’. This will prompt you for current, logged-in user password. Enter the password to become super-user
  2. Open the file /etc/network/interfaces, by typing ‘gedit /etc/network/interfaces’ in the terminal
  3. ppend/edit an entry for eth0 interface as follows:
    auto eth0
    iface eth0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
  4. Save and close the file
  5. Open the file /etc/dnsmasq.conf, by typing ‘gedit /etc/dnsmasq.conf’ in the terminal
  6. Uncomment the line containing “interface=eth0”
  7. Uncomment the line starting with “dhcp-range” to enable integrated DHCP server. The line need to be edited to look like this;
    dhcp-range=192.168.0.50,192.168.0.150,12h

    Here, the ‘dnsmasq’ is allowed to give IP in the range 192.168.0.50 to 192.168.0.150 with a lease time of 12 hours.
  8. Save and close the file
  9. Run, /etc/init.d/networking restart; /etc/init.d/dnsmasq restart

Note: The above setups are one time activity. After setting up the network as mentioned above, for subsequent usage all you need to do is to run the following commands sequentially as superuser (sudo). Ofcourse, make sure the hardware accessorites are connected properly before proceeding.
  • /etc/init.d/networking stop; /etc/init.d/networking start
  • wvdial &
    (wait till it fetches IP address and DNS entries. Otherwise, no use in proceeding further since, there is likely to be a ppp connection problem).
  • /usr/local/sbin/ppp_eth_route
  • /etc/init.d/dnsmasq stop; /etc/init.d/dnsmasq start

You may put the above commands in a shell script for easy usage.

Comments

  1. Great post. I think it is good for visitors. I like this kind of website where has a lot of real information, It proved to be very helpful. Thanks for admin, His creativity, Presentation, Information and all is good.
    home network setup

    ReplyDelete
  2. Thanks Vabna! Good to know this post was helpful to you.

    ReplyDelete

Post a Comment

Popular posts from this blog

Debian Squeeze and Mac OSX Lion - Dual boot

With Mac OSX Snow Leopard, things were much simpler to install and run a Linux operating system just by using rEFIt boot manager utility, on my Mac Mini(4,1 Mid-2010 model). With the introduction of Lion, Apple has introduced a hidden, OS recovery partition. In total, there will be 3 partitions for Mac OSX alone, for Lion. They are ESP (EFI System Partition), Mac OSX installation partition and, the OS recovery partition. Also, as per the GUID Partition Table(GPT) which Mac uses, there can be maximum of 4 primary partitions, with no scope for Extended partitions like in typical MSDOS Partition Table setup. It is also recommended to follow GPT when using Mac.

With all these constraints, I'm actually left with one partition where I can install and run GNU/Linux (in this case, Debian Squeeze). I didn't try resizing an existing Mac OSX installation partition and creating an Ext4 partition for Linux. Rather, I choose to go for fresh installation. You can try with the resizing method…

Creating GRUB/Syslinux splash images

GRUB splash image creation:
Open GIMP application.Create an image of size 640x480 pixels. You may open an existing image and resize it too.Reduce the number of colors to 14 by selecting menu item “Image->Mode->Indexed”. Don’t use any color dithering.Save the resulting image as splash.xpm and close GIMP.Compress the image file by running; gzip splash.xpmCopy the resulting splash.xpm.gz file to /boot/grub.Run update-grub to upgrade the grub configuration to include this splash image.
Syslinux splash image creation:
Open GIMP application.Create an image of size 640x480 pixels. You may open an existing image and resize it too.Reduce the number of colors to 14 by selecting menu item “Image->Mode->Indexed”. Don’t use any color dithering.Save the resulting image as splash.ppm and close GIMP.Install the package syslinux-common by running; apt-get install syslinux-common as sudo/root. Convert the saved image to syslinux format by running; ppmtolss16 ‘#ffffff=7’ <splash.ppm >spl…