Aim:
Set up the Raspberry Pi as a wireless router using the Raspbian OS. The internet connection will be provided by a Huawei E303 USB 3g dongle on the safaricom network in Kenya, though the setup should be similar on most Huawei dongles and 3g networks. The wireless access point will be provided by an Edimax Nano USB Wifi adapter.
Power Source -------->RPI ----> Powered USB HUB -----> 3g Dongle
|
|
Edimax
Wifi
The USB ports of the Pi seem to struggle to provide the power for a 3g dongle, so a powered USB hub is necessary.
After a lot of reading and messing around, I've come up with a step by step guide for setting up my Pi as a wireless internet router. I use this every time I make a fresh setup of Raspbian, which is a fairly regular event. Stumbling round my latest install like a drunken elephant, it never takes me long to screw something up so badly that it's easier just to start from scratch.
As such, this guide assumes that the Raspbian operating system is 'fresh'. It has been tested with the 2012-12-16 release - as soon as I have the time free, I'll update the guide for the newest release. So, the steps I use to set up the 'Pifi' Router are as follows:
This guide and more like it can be found on my blog.
Set up the Raspberry Pi as a wireless router using the Raspbian OS. The internet connection will be provided by a Huawei E303 USB 3g dongle on the safaricom network in Kenya, though the setup should be similar on most Huawei dongles and 3g networks. The wireless access point will be provided by an Edimax Nano USB Wifi adapter.
Power Source -------->RPI ----> Powered USB HUB -----> 3g Dongle
|
|
Edimax
Wifi
The USB ports of the Pi seem to struggle to provide the power for a 3g dongle, so a powered USB hub is necessary.
After a lot of reading and messing around, I've come up with a step by step guide for setting up my Pi as a wireless internet router. I use this every time I make a fresh setup of Raspbian, which is a fairly regular event. Stumbling round my latest install like a drunken elephant, it never takes me long to screw something up so badly that it's easier just to start from scratch.
As such, this guide assumes that the Raspbian operating system is 'fresh'. It has been tested with the 2012-12-16 release - as soon as I have the time free, I'll update the guide for the newest release. So, the steps I use to set up the 'Pifi' Router are as follows:
This guide and more like it can be found on my blog.
Step 1: Make Sure the Pi Can See the 3g Dongle
Gather Information
To get more information about the USB devices connected to the Pi, we use the command 'lsusb'. Open a terminal window and type:
lsusb
should give an output similar to this:
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 008: ID 050d:0234 Belkin Components F5U234 USB 2.0 4-Port Hub
Bus 001 Device 005: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
lsusb lists the usb devices connected to the Pi, either directly or through the hub. I've highlighted the parts of the output that indicates the 3g dongle can be seen by the Pi. Yours should look similar to this, although it will vary from model to model - most 3g dongles on the market seem to be a Huawei of one flavour of another at the moment. So long as there is a mention of 'modem' or 'UMTS', you should be laughing. What you don't want to see is this:
Bus 001 Device 010: ID 12d1:14d1 Huawei Technologies Co., Ltd.
This is an issue that arises because your 3g dongle has a small partition on it containing the 'dashboard' software for windows. Your Pi has detected this partition, and labeled the dongle as a storage device before it had chance to notice the 3g modem waving its arms frantically in the background.
This happened occasionally with my 3g dongle - I would suggest following the next step even if you are feeling smug about your lsusb output at the moment. The next time you reboot your Pi it could detect your dongle as a storage device, throwing you into a fit of depression. Dangerous times
This can all be overcome with the use of usb_modeswitch. To install, in the terminal window type:
sudo apt-get install usb-modeswitch
The clue is in the name - its going to switch the mode of the usb device from 'storage' to 'modem. Yaaaaay. You need to give it some direction though, which will require some googling. The hexidecimal values highlighted here:
Good: Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
Bad: Bus 001 Device 010: ID 12d1:14d1 Huawei Technologies Co., Ltd.
tell the operating system the vendor ID and device ID. More information on USB identification can be found on the debian wiki. Notice that the first 4 characters of the device ID (vendor ID) are the same in both examples, but the last 4 (device ID) have changed. Usb-modeswitch forces the operating system to use the combination that corresponds to the 3g modem.
usb-modeswitch usage
After usb-modeswitch has installed, an entry for your 3g dongle has to be made in /etc/usb_modeswitch.conf. If your device has already been detected, you can find the Device ID in the output from 'lsusb' - the portion highlighted in the examples above. If, however, you have the 'bad' example in your output, you need to find the correct Device ID (second part) for your 3g dongle - a good bet is a google search for '3g dongle model number usb_modeswitch'. Failing that, the search function of the usb-modeswitch forums. Your model number can normally be found somewhere on the device - try popping the cover off and looking for a sticker near where you insert the sim if you cant find it on the outside. We can assume the first part (vendor ID) is correct in both situations.
After a bit of research, the information I had to amend to the config file amounted to this:
DefaultVendor = 0x12d1
DefaultProduct = 0x1506
MessageEndPoint = "0x01"
MessageContent = "55534243000000000000000000000011060000000000000000 000000000000"
Once you have found the correct device ID, copy and paste the information above into a text editor. Amend the information to suit your own setup, deleting the bottom two lines if they are not needed - I'm not going to claim to understand the MessageEndPoint or MessageContent fields: They were part of the solution I found here - credit goes to krishnamohan of the fedoraforum.org site. Your device may or may not require them. Make sure to include the '0x' before the vendor and device IDs - this lets the Pi know that they are hexidecimal values.
To add this information to the usb-modeswitch config file, open the file for editing by issuing the following command in the terminal window:
sudo nano /etc/usb_modeswitch.conf
Paste the Device ID information from the text editor to the bottom of the config file you just opened in the terminal window. Hit Ctrl+X, y, Enter to exit and save changes.
Reboot your Pi and run 'lsusb', observing the output - if you found the right Device ID, you should see something to the 'good' output example shown above.
To get more information about the USB devices connected to the Pi, we use the command 'lsusb'. Open a terminal window and type:
lsusb
should give an output similar to this:
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 008: ID 050d:0234 Belkin Components F5U234 USB 2.0 4-Port Hub
Bus 001 Device 005: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
lsusb lists the usb devices connected to the Pi, either directly or through the hub. I've highlighted the parts of the output that indicates the 3g dongle can be seen by the Pi. Yours should look similar to this, although it will vary from model to model - most 3g dongles on the market seem to be a Huawei of one flavour of another at the moment. So long as there is a mention of 'modem' or 'UMTS', you should be laughing. What you don't want to see is this:
Bus 001 Device 010: ID 12d1:14d1 Huawei Technologies Co., Ltd.
This is an issue that arises because your 3g dongle has a small partition on it containing the 'dashboard' software for windows. Your Pi has detected this partition, and labeled the dongle as a storage device before it had chance to notice the 3g modem waving its arms frantically in the background.
This happened occasionally with my 3g dongle - I would suggest following the next step even if you are feeling smug about your lsusb output at the moment. The next time you reboot your Pi it could detect your dongle as a storage device, throwing you into a fit of depression. Dangerous times
This can all be overcome with the use of usb_modeswitch. To install, in the terminal window type:
sudo apt-get install usb-modeswitch
The clue is in the name - its going to switch the mode of the usb device from 'storage' to 'modem. Yaaaaay. You need to give it some direction though, which will require some googling. The hexidecimal values highlighted here:
Good: Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
Bad: Bus 001 Device 010: ID 12d1:14d1 Huawei Technologies Co., Ltd.
tell the operating system the vendor ID and device ID. More information on USB identification can be found on the debian wiki. Notice that the first 4 characters of the device ID (vendor ID) are the same in both examples, but the last 4 (device ID) have changed. Usb-modeswitch forces the operating system to use the combination that corresponds to the 3g modem.
usb-modeswitch usage
After usb-modeswitch has installed, an entry for your 3g dongle has to be made in /etc/usb_modeswitch.conf. If your device has already been detected, you can find the Device ID in the output from 'lsusb' - the portion highlighted in the examples above. If, however, you have the 'bad' example in your output, you need to find the correct Device ID (second part) for your 3g dongle - a good bet is a google search for '3g dongle model number usb_modeswitch'. Failing that, the search function of the usb-modeswitch forums. Your model number can normally be found somewhere on the device - try popping the cover off and looking for a sticker near where you insert the sim if you cant find it on the outside. We can assume the first part (vendor ID) is correct in both situations.
After a bit of research, the information I had to amend to the config file amounted to this:
DefaultVendor = 0x12d1
DefaultProduct = 0x1506
MessageEndPoint = "0x01"
MessageContent = "55534243000000000000000000000011060000000000000000 000000000000"
Once you have found the correct device ID, copy and paste the information above into a text editor. Amend the information to suit your own setup, deleting the bottom two lines if they are not needed - I'm not going to claim to understand the MessageEndPoint or MessageContent fields: They were part of the solution I found here - credit goes to krishnamohan of the fedoraforum.org site. Your device may or may not require them. Make sure to include the '0x' before the vendor and device IDs - this lets the Pi know that they are hexidecimal values.
To add this information to the usb-modeswitch config file, open the file for editing by issuing the following command in the terminal window:
sudo nano /etc/usb_modeswitch.conf
Paste the Device ID information from the text editor to the bottom of the config file you just opened in the terminal window. Hit Ctrl+X, y, Enter to exit and save changes.
Reboot your Pi and run 'lsusb', observing the output - if you found the right Device ID, you should see something to the 'good' output example shown above.
Step 2: Download and Setup Ppp, UMTSKeeper and Sakis3g
pppd
The ppp package will install the point to point protocol daemon, which will manage the connection between you and your 3g provider. The package can be installed via the terminal with the command:
sudo apt-get install ppp
Nothing further needs to happen with pppd, it should just sit there in the background, as a daemon is supposed to, waiting for Sakis3g to poke it in the ribs. Want to learn more? Here is a link to the Wikipedia page on daemons in linux.
UMTSKeeper
UMTSkeeper is used to automatically reconnect the 3g dongle using the Sakis3g script should the connection drop, which actually happens with monotonous regularity in Kenya.
Download and unpack UMTSkeeper by issuing the following commands from the terminal window:
sudo mkdir umtskeeper
cd umtskeeper
sudo wget "http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz"
sudo tar -xzvf umtskeeper.gz
sudo chmod +x umtskeeper
The first command created a folder called 'umtskeeper' in the current directory you are in. To confirm what this directory is, type 'pwd'. Make note of the output, as we will need the full path to automate UMTS keeper later. Now we will download Sakis3g into the same directory to keep things simple.
Sakis3g
Sakis3g is a script used to make a 3g connection. You need to be able to provide a few details: your APN, the PIN for your sim card and your username and password if your provider requires them. This information can (hopefully) be found on your providers website or in the documentation that came with your simcard/dongle. If not, a search on google for 'your provider APN settings' should unearth them.
The sakis-3g.org website has been down for some time. Fortunately somebody has uploaded a copy of the script to sourceforge. To download and unpack it, issue the following commands from the terminal window:
sudo wget "http://downloads.sourceforge.net/project/vim-n4n0/sakis3g.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvim-n4n0%2Ffiles%2F&ts=1363537696&use_mirror=tene~t" -O sakis3g.tar.gz
sudo tar -xzvf sakis36.tar.gz
sudo chmod +x sakis3g
Before going further, you should attempt to make a 3g connection using the sakis3g script alone, proving everything you've done up till now works. Sakis3g has an interactive mode, which will prompt you for information regarding your 3g connection. In the terminal window, type:
./sakis3g --interactive
and follow the prompts on screen. If you have no APN user or password, enter '0'. Once a connection has been made, make sure you can browse the internet, or issue a ping from the terminal window:
ping -c 4 google.com
Now test UMTSkeeper. The command at first may look a bit confusing (the details are for my connection):
./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='safaricom' SIM_PIN='1234' APN_USER='saf' APN_PASS='data'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no'
Breaking it down a little, these are the areas that you will need to change:
USBMODEM: The Device ID we found using the lsusb command earlier
CUSTOM_APN, APN_USER, APN_PASS, SIM_PIN: Information about your sim card and your providers data network.
A full breakdown of the paramaters can be found on the UMTSKeeper site..
Once you are satisfied UMTSKeeper is working in harmony with Sakis3g, we can edit /etc/rc.local so that it starts when the operating system boots. In the terminal window, type:
sudo nano /etc/rc.local
and add the following single line, edited to show your path to the umtsfolder you found with the 'pwd' command earlier:
PATH GOES HERE/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='safaricom' SIM_PIN='1234' APN_USER='saf' APN_PASS='data'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no' &
Exit, saving changes.
The ppp package will install the point to point protocol daemon, which will manage the connection between you and your 3g provider. The package can be installed via the terminal with the command:
sudo apt-get install ppp
Nothing further needs to happen with pppd, it should just sit there in the background, as a daemon is supposed to, waiting for Sakis3g to poke it in the ribs. Want to learn more? Here is a link to the Wikipedia page on daemons in linux.
UMTSKeeper
UMTSkeeper is used to automatically reconnect the 3g dongle using the Sakis3g script should the connection drop, which actually happens with monotonous regularity in Kenya.
Download and unpack UMTSkeeper by issuing the following commands from the terminal window:
sudo mkdir umtskeeper
cd umtskeeper
sudo wget "http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz"
sudo tar -xzvf umtskeeper.gz
sudo chmod +x umtskeeper
The first command created a folder called 'umtskeeper' in the current directory you are in. To confirm what this directory is, type 'pwd'. Make note of the output, as we will need the full path to automate UMTS keeper later. Now we will download Sakis3g into the same directory to keep things simple.
Sakis3g
Sakis3g is a script used to make a 3g connection. You need to be able to provide a few details: your APN, the PIN for your sim card and your username and password if your provider requires them. This information can (hopefully) be found on your providers website or in the documentation that came with your simcard/dongle. If not, a search on google for 'your provider APN settings' should unearth them.
The sakis-3g.org website has been down for some time. Fortunately somebody has uploaded a copy of the script to sourceforge. To download and unpack it, issue the following commands from the terminal window:
sudo wget "http://downloads.sourceforge.net/project/vim-n4n0/sakis3g.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvim-n4n0%2Ffiles%2F&ts=1363537696&use_mirror=tene~t" -O sakis3g.tar.gz
sudo tar -xzvf sakis36.tar.gz
sudo chmod +x sakis3g
Before going further, you should attempt to make a 3g connection using the sakis3g script alone, proving everything you've done up till now works. Sakis3g has an interactive mode, which will prompt you for information regarding your 3g connection. In the terminal window, type:
./sakis3g --interactive
and follow the prompts on screen. If you have no APN user or password, enter '0'. Once a connection has been made, make sure you can browse the internet, or issue a ping from the terminal window:
ping -c 4 google.com
Now test UMTSkeeper. The command at first may look a bit confusing (the details are for my connection):
./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='safaricom' SIM_PIN='1234' APN_USER='saf' APN_PASS='data'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no'
Breaking it down a little, these are the areas that you will need to change:
USBMODEM: The Device ID we found using the lsusb command earlier
CUSTOM_APN, APN_USER, APN_PASS, SIM_PIN: Information about your sim card and your providers data network.
A full breakdown of the paramaters can be found on the UMTSKeeper site..
Once you are satisfied UMTSKeeper is working in harmony with Sakis3g, we can edit /etc/rc.local so that it starts when the operating system boots. In the terminal window, type:
sudo nano /etc/rc.local
and add the following single line, edited to show your path to the umtsfolder you found with the 'pwd' command earlier:
PATH GOES HERE/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='safaricom' SIM_PIN='1234' APN_USER='saf' APN_PASS='data'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no' &
Exit, saving changes.
Step 3: Setup Wireless Access Point
The final hurdle involves setting up the wireless access point.
The chiipset in the Edimax Wifi adapter does not work 'out of the box' as an access point, so the process is a little disjointed. One step at a time:
Install 'hostapd' specifically built for Edimax adapter
hostapd manages the authentication on your wireless network. The version in the debian repositories in not compatible with the Edimax adapter - thankfully someone has put together a version which includes the correct drivers. Follow this guide to install the updated version of hostapd.
The guide mentions creating a configuration file. This should contain the following:
interface=wlan0
ssid=NAME OF YOUR WIRELESS NETWORK GOES HERE
channel=10
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8188CUS
manufacturer=Realtek
wpa=2 # This sets the security settings to WPA2
wpa_passphrase=PASSWORD FOR NETWORK GOES HERE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
# Other settings
beacon_int=100
auth_algs=3
wmm_enabled=1
The chiipset in the Edimax Wifi adapter does not work 'out of the box' as an access point, so the process is a little disjointed. One step at a time:
Install 'hostapd' specifically built for Edimax adapter
hostapd manages the authentication on your wireless network. The version in the debian repositories in not compatible with the Edimax adapter - thankfully someone has put together a version which includes the correct drivers. Follow this guide to install the updated version of hostapd.
The guide mentions creating a configuration file. This should contain the following:
interface=wlan0
ssid=NAME OF YOUR WIRELESS NETWORK GOES HERE
channel=10
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8188CUS
manufacturer=Realtek
wpa=2 # This sets the security settings to WPA2
wpa_passphrase=PASSWORD FOR NETWORK GOES HERE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
# Other settings
beacon_int=100
auth_algs=3
wmm_enabled=1
Step 4: Configure NAT
NAT allows many clients on your private network to use the single public (internet side) ip address of the 3g dongle. The config for this part is stolen from the elinux.org guide.
First, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:
net.ipv4.ip_forward=1
This will enable NAT in the kernel. Second, run the following commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Your Pi is now NAT-ing. To make this permanent so you don't have to run the commands after each reboot, run the following command:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:
up iptables-restore < /etc/iptables.ipv4.nat
First, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:
net.ipv4.ip_forward=1
This will enable NAT in the kernel. Second, run the following commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Your Pi is now NAT-ing. To make this permanent so you don't have to run the commands after each reboot, run the following command:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:
up iptables-restore < /etc/iptables.ipv4.nat
Step 5: Configure Wireless Interface and DHCP
The Edimax adapter needs to be given a static IP address. In the terminal window, type:
sudo nano /etc/network/interfaces
Amend the wlan0 entry so it looks like this:
#allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.1
network 10.0.0.0
netmask 255.255.255.0
To turn our Pi into a DHCP server, we will install dnsmasq from the terminal:
sudo apt-get install dnsmasq
Once dnsmasq has been installed, we need to edit its config file. As usual, from the terminal:
sudo nano /etc/dnsmasq.conf
amend these 2 lines to the end of the config file:
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.10,255.255.255.0,12h
These lines set the DHCP server to listen on wlan0, and hand out a 12 hour lease to a maximum of 9 clients. If you need more clients, increase the number highlighted.
Fingers crossed!
Your Pi has now been configured to connect automatically to your providers 3g network via the USB dongle, and set the Edimax adapter as a wireless access point for up to 9 clients on the 10.0.0.0 network.
Now cross your fingers, reboot your Pi and try to connect from one of the client machines! If it doesn't work or you receive any errors during any of this guide, please leave a comment and I'll do my best to help you.
Before you proceed, make sure you have read and understood the license agreement. For your convenience, I made an excerpt. It's not an endless read of tyring legal stuff.
← more for beginners →
← more for beginners →
In a terminal, this will download the archive, check if you indeed obtained the file from this site (the correct md5sum output should be: a456e1467057f78d53f4749adcd26d12 umtskeeper.tar.gz), extract the scripts, and make them executable (just in case...) - input line-by-line:
cd ~
pwd
mkdir umtskeeper
cd umtskeeper
wget "http://mintakaconciencia.net/squares/umtskeeper/src/umtskeeper.tar.gz"
md5sum umtskeeper.tar.gz
tar -xzvf umtskeeper.tar.gz
chmod +x sakis3g umtskeeper resetusb
(with older versions only)
pwd
mkdir umtskeeper
cd umtskeeper
wget "http://mintakaconciencia.net/squares/umtskeeper/src/umtskeeper.tar.gz"
md5sum umtskeeper.tar.gz
tar -xzvf umtskeeper.tar.gz
chmod +x sakis3g umtskeeper resetusb
(with older versions only)
Also make sure that your system properly detects the modem (i.e. that usb_modeswitch works).
← more on usb_modeswitch and Network Manager →
← more on usb_modeswitch and Network Manager →
First Run
Please be aware that you should never run a downloaded script with root privileges unless you are sure what you do and that you indeed got the original file from the original source (not some trojan from a spy-in-the-middle). Checking the MD5 can help but doesn't make you secure.
The clever way is to first connect manually with Sakis3G in interactive mode. Sakis3G will give you hints for the options to use. Do it as root:
sudo ./sakis3g --interactive
Hint: if you are asked for APN user or APN password but you have none, enter "0".
If your connection works in interactive mode, unplug and re-plug your modem and try with UMTSkeeper with all the switches and options, also as root.
For example (this is a single line, mind the quotes!):
For example (this is a single line, mind the quotes!):
sudo ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:140c' SIM_PIN='1234' APN='CUSTOM_APN' CUSTOM_APN='provider.com' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'
UMTSkeeper will stay running after this. To end it, press the key combination CTRL+C.
Sidenote: You can watch the log flow by typing tail -f /var/log/umtskeeper.log if you like. End the watch with the key combination CTRL+C.
When run for the first time some log files will be created, among them /var/log/umtskeeper.log (option --log, the main log file), umtskeeper.stat.html (HTML statistics file to view in your web browser), and umtskeeper.stat (the file which keeps the numbers for the next run). Without the option --silent, the log is also printed on screen. It should contain something like this:
| 1 | cat /var/log/umtskeeper.log | |
| 2 | 2013-07-23 12:16:05 Start: PID = 21338 | |
| 3 | Main stats file not found. | This is normal for the first run when the main statistics file umtskeeper.stat is not yet present. Such an output should only make you worry if they happen with subsequent starts. Sometimes, UMTSkeeper might be interrupted just when it is in the middle of writing the stats file, which would be fatal. For such (rare) cases, a backup of that file is kept. |
| 4 | Main stats file is incomplete. This happens in rare cases when UMTSkeeper is killed in the wrong moment. Trying to load backup file. This can cause slight inacurracies in the statistics. | |
| 5 | Main stats file backup not found. Possibly this program is being run for the very first time. | |
| 6 | 2013-07-23 12:16:05 stats period = 8s, connection check period = 32s | |
| 7 | Monthly stats file not found, setting up a new one. | New statistics files have been created. These are comma-separated-values files which you can import into your favorite spreadsheet software to plot lenghty graphs etc. - these statistics are kept until you manually delete them. The files are: umtskeeper.hourly.csv, umtskeeper.daily.csv, umtskeeper.monthly.csv. |
| 8 | Daily stats file not found, setting up a new one. | |
| 9 | Hourly stats file not found, setting up a new one. | |
| 10 | Internet status: | |
| 11 | Cell network: No modem plugged. | This is OK if you have the usual type of modem that first registers as a storage device to the system. The script will wait until the device is switched to modem mode. |
| 12 | 2013-07-23 12:16:41 Internet connection is DOWN. Calling Sakis3G connect... | |
| 13 | Sakis3G cmdLine: nice ./sakis3g connect --sudo --console USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:140c' SIM_PIN='1234' APN='CUSTOM_APN' CUSTOM_APN='provider.com' APN_USER='0' APN_PASS='0' | Commands that are being sent to Sakis3G. Use this for trying manually if something doesn't work. Sakis3G is called by the command nice which means that the program will run with lower priority. S3G is CPU hungry so you want it to play nicely and not interrupt other running processes. |
| 14 | Sakis3G says... | |
| 15 | E1550 connected to PROVIDER (13579). | The connection has been established. |
| 16 | 2013-07-23 12:17:14 Testing connection... | |
| 17 | 2013-07-23 12:17:24 Success... we are online! |
If you unplug your modem now and re-plug it again then the connection should be established automatically. Give usb_modeswitch and Sakis3G a little patience.
Automatic Start
Last, you want to start UMTSkeeper automatically after boot. Put a line into /etc/rc.local like this (it's a single line which will make it run in the background and redirect screen output to an error.log file): /etc/rc.local has to be edited by the root user. Replace the path /home/mintaka/in this example by the path you found out previously.
sudo nano /home/pi/.bashrc
cd umtskeeper/
sudo ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='1234' APN='gpinternet' CUSTOM_APN='gpinternet' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'
sudo nano /home/pi/.bashrc
cd umtskeeper/
sudo ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='1234' APN='gpinternet' CUSTOM_APN='gpinternet' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'
/home/mintaka/umtskeeper/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:140c' SIM_PIN='1234' APN='CUSTOM_APN' CUSTOM_APN='provider.com' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no' --httpserver &>> /home/mintaka/umtskeeper/error.log &
A line for only logging transfer statistics on wlan0 would for example look like this:
/home/mintaka/umtskeeper/umtskeeper --logonly --log --silent --monthstart 14 --iface 'wlan0' --httpserver &>> /home/mintaka/umtskeeper/error.log &
Dynamic DNS updater and e-mail notification
There are two ways of using DDNS with UMTSkeeper: either let it call an external command line tool (if your DNS provider has a proprietary protocol), or use the internal update methods. Two methods are currently implemented: one is for the "freedns" style method which uses only an URL with an update code, and the other is the so-called "Members NIC Update API", invented by dyn.com and widely adopted by other services. The updater has been tested with freedns.afraid.org, dyn.com (dyndns.com) and no-ip.com.
The DNS updater must be configured by configuration file, as the configuration potentially contains sensitive data. See the sample config file for more information.
Notice, that if you use the DNS updater together with the webserver then your transfer statistics will be more easily accessible from the internet. If you don't want this, you can obfuscate the server by using a port other than standard HTTP port 80 (default is 8000), or you can secure it by using the IP whitelist feature. By all means, if those transfer statistics contain sensitive data (all human-generated traffic does!), don't get them over public nets without encryption. Security is your responsibility, don't take this lightly. Read my advice.
UMTSkeeper can also notify you about IP changes by e-mail. This must be configured by configuration file, as the configuration will contain sensitive data.
AT LAST
cd umtskeepersudo ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='1234' APN='gpinternet' CUSTOM_APN='gpinternet' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --nat 'no'
####### Modem Connection Error #############
Mode switch
# type: lsusb
# Show# Bus 001 Device 006: ID 12d1:15ca Huawei Technologies Co., Ltd. E3131 3G/UMTS/HSPA+ Modem (Mass Storage Mode)
# This is mass storage mode we need to change modem mode
# type
# sudo usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 15ca -M 55534243123456780000000000000011060000000000000000000000000000
# lsusb
Bus 001 Device 008: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard





Comments
Post a Comment