Pimping Sprint Mobile Broadband With Linux
Written by Mr-Oss   
Saturday, 09 February 2008

Image Congratulations on finding the best sprint mobile broadband linux tutorial on the internet.  Today we will be demonstrating how to use sprint mobile broadband with linux and even share your sprint connection with your wireless router.  We will be using kubuntu linux to accomplish a laptop router that will take our sprint mobile broadband one step past merely connecting to the internet.  This article will show you step by step how to setup your sprint mobile broadband card to route traffic for your wireless router. 

Your Ad Here

The hardware we will be using for this include the Novatel U727 USB adapter, a linksys wrt54g, and a laptop computer with kubuntu 7.10 loaded on it.  Image  Using these components we will split the usb adapter off to ethernet, which will then be plugged into the rj45 plug on our laptop.  Using iptables for routing purposes we will setup a virtual router that will then feed the wan port of our wrt54g which will provide 802.11 wireless capabilities for the rest of the computers on our network.  Once in place you can setup your own wifi hot-spot anywhere that you get coverage for sprint data card.

Step 1... Making The Connection

Our connection to the internet is provided by sprint mobile broadband services.  For 59.95 a month you can get unlimited data transfer that works almost everywhere http://www.nextel.com/en/solutions/mobile_broadband/index.shtmlSprint offers many styles of data cards that work with linux.  This tutorial uses the Novatel U727 USB adapter.  The only way linux can take use of the sprint card is by treating it as a dialup modem.  Although kppp can be used this tutorial will be focusing on the use of the wvdial program.  The wvdial program seems to be installed by default on kubuntu 7.10.  If you don't currently have wvdial you can get it using the following command while connected to the internet.  

 sudo apt-get install wvdial

 Now that we have wvdial installed we will need to setup the appropriate configuration file.  Please note that this tutorial assumes you are using a USB style adapter which determines our device in the config file.  If you have an alternate sprint card you will need to modify the dev settings for your system.  The file we will be setting up for wvdial is the /etc/wvdial.conf file.  This file can be created or edited with the following command.

sudo vi /etc/wvdial.conf

The /etc/wvdial.conf file should contain the following lines.

[Dialer Defaults]
Modem=/dev/ttyUSB0
Baud=460800
Init1=ATZ
Init2=ATQ0 V1 E1 S0=0 &C1 &D2+FCLASS=0
ISDN=0
Modem Type=USB Modem
Phone=#777
Username=''
Password=''
Carrier Check=no
Stupid Mode=yes

Now that everything has been setup for the wvdial program we will need to load up the appropriate kernel modules to power our device.  The first thing we will need to do is remove the usb serial module from our running system and reload the usbserial module with our vendor and product specific flags.  To remove the currently running usbserial module we use the following command.

sudo modprobe -r usbserial

We have removed the usbserial kernel module and now we will reload it with the correct flags specific to the Novatel U727 USB adapter.  To accomplish this we use the following command.

 sudo modprobe usbserial vendor=0x1410 product=0x4100

That command will load up the usbserial kernel module with the correct parameters.  If your card is different than the Novatel U727 then please refer to the following chart for your specific vendor and product modprobe parameters. 

BROADBAND MODEM MODEL 
 VENDOR ID   PRODUCT ID   FORM FACTOR  
 NOVATEL MERLIN S620 0x1410
 0x1110
  PC CARD
 NOVATEL MERLIN S720 0x1410 0x1130  PC CARD
 NOVATEL OVATION U720 0x1410 0x2110 USB MODEM
 NOVATEL MERLIN EX720 0x1410 0x1120 EXPRESS CARD
 NOVATEL U727 0x1410 0x4100 USB MODEM
 PANTECH PX-500 0x106c
 0x3702
 PC CARD
 SIERRA AC580   
 0x1199 0x0112
 PC CARD
 SIERRA AC595 0x1199 0x0019 PC CARD
 SIERRA AC595U 
 0x1199 0x120
 USB MODEM
 SIERRA AC597E
 0x1199 0x0021
 EXPRESS CARD

 The chart shown above was taken from the sprint linux installation guide.  The sprint linux installation guide can be found at http://sprint.com/downloads  Now that we have run the two modprobe commands we need to verify that they actually did something useful.  To make sure that our system has loaded the modules for communications purposes we use the following command.

dmesg | grep ttyUSB

we should see output that contains the following

[  307.718870] usb 1-1: generic converter now attached to ttyUSB0
[  307.720935] usb 1-1: generic converter now attached to ttyUSB1
[  307.722933] usb 1-1: generic converter now attached to ttyUSB2
[  307.724941] usb 1-1: generic converter now attached to ttyUSB3

GREAT! now we are up and attached lets kick off the dialer and see if we can finish up step 1 of connecting to the internet.  To start up the dialer that we setup earlier we issue the following command.

sudo wvdial

 After issuing the wvdial command you should see something similar to the following output.

WvDial<*1>: WvDial: Internet dialer version 1.56
WvModem<*1>: Cannot get information for serial port.
WvDial<*1>: Initializing modem.
WvDial<*1>: Sending: ATZ
WvDial Modem<*1>: ATZ
WvDial Modem<*1>: OK
WvDial<*1>: Sending: ATQ0 V1 E1 S0=0 &C1 &D2+FCLASS=0
WvDial Modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2+FCLASS=0
WvDial Modem<*1>: OK
WvDial<*1>: Modem initialized.
WvDial<*1>: Sending: ATDT#777
WvDial<*1>: Waiting for carrier.
WvDial Modem<*1>: ATDT#777
WvDial Modem<*1>: CONNECT
WvDial<*1>: Carrier detected.  Starting PPP immediately.
WvDial<Notice>: Starting pppd at Sun Feb 10 09:51:43 2008
WvDial<Notice>: Pid of pppd: 6578
WvDial<*1>: Using interface ppp0
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: local  IP address 70.43.28.21
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: remote IP address 69.38.92.49
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: primary   DNS address 69.58.10.91
WvDial<*1>: pppd: ø06][04]È[06][04]
WvDial<*1>: secondary DNS address 69.23.72.191
WvDial<*1>: pppd: ø06][04]È[06][04]

 

Excellent!, we are now connected to sprint using linux!  One thing to note is that you will want to write down the primary and secondary DNS addresses for use later when we setup our wireless router.  Now you should be able to open up a browser and connect to the internet.  I've noticed that the connection doesn't seem to run as fast in linux but we will have the abililty to split this connection off and send it to more than one computer.  Now step 1 is complete we need to proceed to the next step.

 Step 2 ....Image

Setting Up The Ethernet Route

Now that we have successfully connected to the internet we will use our laptop's ethernet card to serve out the connection to our linksys router on the internal network.  We will be using iptables to create a route between ppp0 and eth0 on our system.  

 OUR NETWORK WILL LOOK LIKE THIS

USBMODEM

<- USB ->

LAPTOP RUNNIN

KUBUNTU 7.10  

<-CATEGORY 5 ETHERNET->  LINKSYS  WRT 54 G
 <-WIRELESS NETWORK->

WIRELESS CLIENT

EEE PC 2G

 (public ip)

ppp0 

 ppp connection

  IPTables 

 

 Firewall

 eth0 on laptop

192.168.0.1

 WAN static ip

192.168.0.2

dns server

set to values

of wvdial dns 

Private IP 

192.168.1.1

Private IP

192.168.1.x

(Dynamically  Assigned) 

 As you can see from the above diagram the next step in our network is to create the ethernet interface and build the firewall.  First we will be setting the internel ethernet adapter eth0 to the ip address of 192.168.0.1.  This can be achived by the following command

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255

Now we have our internal ip address for eth0 statically assigned to 192.168.0.1 which will be the default route for our wireless router that is introduced in the next step.  We have configured the ethernet interface and will now need to setup a firewall to bridge ppp0 ( sprint ) across to our internal interface eth0.  To setup the firewall I used a super handy online firewall generator.  http://easyfwgen.morizot.net/gen/ 

 The internet interface was set to ppp0 and the gateway/firewall option was used.  On the next page we set the internal network adapter to eth0, set the internal ethernet address to 192.168.0.1, we set the internal network to 192.168.0.0/24, and the internal network broadcast to 192.168.0.255 then hit generate. We are then given the generated code we will need to route traffic on our network.  Copy this text off to your favorite editor and name it firewall.sh.  Here is our firewall that was generated

http://mr-oss.com/images/stories/sprint_mobile_broadband/firewall.txt 

Save the firewall to your home directory and name it firewall.sh.  Once you have the firewall saved we will need to change the permission settings and make sure the firewall is executable.  To do this change directories to where your firewall is located and issue the following command.

sudo chmod 755 firewall.sh

Now that the firewall is executable we need to load it.  To load the firewall we need to use the following command 

sudo ./firewall.sh

If the command completes successfully you should see the following output on your terminal. 

Loading kernel modules ...
net.ipv4.ip_forward = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.all.log_martians = 1
Flushing Tables ...
Create and populate custom rule chains ...
Process INPUT chain ...
Process FORWARD chain ...
Process OUTPUT chain ...
Load rules for nat table ...
Load rules for mangle table ... 

Now we have our kubuntu linux laptop router setup to run a ppp0 internet connection and share it with the eth0 interface.  This will allow us to plugin the linksys wrt54g's WAN interface into the internal network adapter eth0 on the laptop.  That will bring us to the third step setting up the wireless router

Step 3 ... Image 

Setting Up The Wireless Router 

 Now that we have our sprint adapter connected to the internet, our ethernet interface statically configured to 192.168.0.1, and our firewall loaded to act as a gateway between interface ppp0 and eth0 we will need to finish our mobile hot spot by configuring the linksys wrt54g.  

WE WILL BE USING THE EEE PC 2G AS A CLIENT TO CONNECT ON THE PRIVATE SIDE OF THE WRT54G

Image 

Connecting to the private side of your router for configuration purposes can take place over ethernet (ports 1-x) but not on the WAN interface.  You could also connect to the router using the wireless interface.   We will be connecting to the router's client side on a seperate computer over the wireless interface.  Although we are using a WRT54G you can use any wireless router you choose.  You will need to login to the administration setup page on your wireless router.  Once you login to the wireless router's administration setup page we will need to configure the following settings.

 Router Admin

CONNECTION TYPE

   SET TO THESE VALUES  

 INTERNET (PUBLIC / WAN) IP ADDRESS
192.168.0.2  ( the wan port on our router STATIC IP ) 
 SUBNET MASK
255.255.255.0 
 DEFAULT GATEWAY
192.168.0.1 ( our linux laptop router ) 
 STATIC DNS 1
 69.58.10.91 ( from wvdial output earlier )
 STATIC DNS 2  69.23.72.191 ( from wvdial output earlier )
 ROUTER PRIVATE IP ADDRESS
192.168.1.1 ( wireless / wired client side )
 ROUTER PRIVATE SUBNET
255.255.255.0 
 ROUTER DHCP SERVER
ENABLED 

Once you have successfully configured your wireless router to the settings defined in the above chart, we are ready to jump online.  On the client computer, in our case the EEE PC 2G surf, we browse for the wireless network's ssid.  After locating the wireless ssid we connect to the wireless network and receive and ip address of 192.168.1.137 from dhcp.  Now that we have connected to the wireless router we will need to plug in the WAN interface to feed the router through the sprint connection thanks to our firewall.  With a normal category 5 ethernet cable, plug one end into the WAN port on the wireless router.  Next, plug the other end into the ethernet port on the linux laptop (eth0 on kubuntu).  Once the cable is in place, jump back on the client computer ( our EEE PC ).  Open your favorite web browser, in our case firefox, and attempt to get online.  If everything was successful you now have a working "hot spot" using your linux laptop, sprint mobile broadband, and your wireless router.   

 

Check out the next page for a picture of our network and some tips on "gotchas" that we encountered during this hack.

A Picture Of Our Network Setup

 

 Net1

 net2

 

Gotchas We Encountered During This Hack

 One problem we seemed to run into was with wvdial not seeing the device /dev/ttyUSB0.  To resolve this problem we re-created the device /dev/ttyUSB0 after removing it.  We used the following command to accomplish this.

sudo rm -rf /dev/ttyUSB0

After removing the device we recreated the device with the following commands.

 sudo mknod /dev/ttyUSB0 c 188 0
 sudo chown root:dialout /dev/ttyUSB0
 sudo chmod 660 /dev/ttyUSB0

 

*PLEASE NOTE* the number 188 corresponds to a device "group". One suggestion for obtaining this number on your system is to perform the command

sudo ls -al /dev/ttyUSB0

Take note of the number on your system and use it in-place of 188 in the mknod command listed above.  Once you re-create the device then you will have to perform the module unload and load commands again.  Use the following command to unload the usbserial module on your system.

sudo modprobe -r usbserial
 

Then once you have unloaded the usbserial module we will need to reload it with our device specific parameters.

sudo modprobe usbserial vendor=0x1410 product=0x4100

Upon successfully reloading the kernel module you will need to start the dialer again.

sudo wvdial

If it works, that's great!  If it is still complaining about the device being missing give it a few minutes and try the dialer again.  This was the most frustrating part of this hack.  Check back for updates on how to correct this problem.  We will also be posting our monster script that just does it all for you very soon.  Stay Tuned

Hopefully you enjoyed this hack as much as we did.

If this was helpful, do us a favor and click our ads.

Sincerely,

The Mr-Oss Team 

UPDATE!  We have posted the master script that goes along with this tutorial.  You can find it HERE

Enjoy!

Mr-Oss 

 

 

 

Last Updated ( Saturday, 08 November 2008 )