Featured Post

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.
  1. Save and close the file
  2. 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
    
    Save and close the file.
  3. 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
    
    Save and close the file
  4. Open the file /etc/dnsmasq.conf, by typing ‘gedit /etc/dnsmasq.conf’ in the terminal
  5. Uncomment the line containing “interface=eth0”
  6. 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.
  7. Save and close the file
  8. 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
  3. Looks a little bit complicated but thanks anyway! .

    ReplyDelete

Post a Comment

Popular posts from this blog

How to extract an initrd image

Debian Squeeze and Mac OSX Lion - Dual boot