Introduction: 3G Wireless Router Based on Raspberry Pi2

Picture of 3G Wireless Router Based on Raspberry Pi2

This is a 3G wireless router based on Raspberry Pi 2. The raspberry pi which is capable of running various linux distros can be used to do various stuffs and interesting utilities. I had made this 3g router with the help of raspberry pi 2 along with TP-LINK TL-WN722N and MTS cdma data card but any data card with good linux drivers can be used. As well as any wifi usb adapters with AP mode can be used.

Step 1: Requirements

  • USB Power Adapter with 5V and 1A or 2A output
  • Raspberry Pi 2
  • 3G usb data card
  • USB wifi adapter with AP mode support (TP-LINK TL-WN722N)
  • 4gb or 8gb memory card with Raspbian OS preinstalled. ( For installation guide just google it.)
  • Ethernet cable (optional)
  • Monitor, keyboard, mouse (optional if configuration is done through SSH).

Step 2: Setup

Basically we are going to connect the raspberry pi 2 to the internet through 3g data card. And going to share the network through Ethernet and WLAN. For detailed configurations you can view this link ( https://wiki.archlinux.org/index.php/Sharing_PPP_C... ).

  • As you boot into raspbian os for the first time, enable sshd through raspi-config page or manually through terminal. Don't boot into graphical interface and dont enable booting into graphical mode. Because that is not necessary.
  • Connect the raspberry pi to the power and ethernet cable from PC or router you already have which should be connected to internet ( necessary to complete the setup).
  • After raspberry pi is connected to the internet. Update and upgrade the raspbian os by typing " sudo apt-get update " and " sudo apt-get upgrade "
  • Now install following packages " sudo apt-get install iptables dnsmasq wvdial usb-modeswitch hostapd iw" .
  • This completes the installation of required packages for the 3G wireless router to work properly. Now we move on to the configurations and necessary steps to complete the build.

Step 3: WVDIAL Setup

  • Type this in terminal: " sudo nano /etc/wvdial.conf ". then edit the configuration to suit your 3g data card. I used a cdma data card.

[Dialer Defaults]

Init1 = ATZ

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

Modem Type = Analog Modem

Baud = 460800

New PPPD = yes

Modem = /dev/ttyUSB0

ISDN = 0

Phone = ####

Password = password

Username = username

stupid mode = 1

  • Copy and paste this in the wvdial.conf file but put your username and password and change the phone dial number to the appropriate number of your ISP provider.
  • Press CTRL + X and type yes to save the configuration file.
  • This completes the necessary setup to connect to the internet. now by typing " sudo wvdial " in the terminal you can connect to the web.

Step 4: Router Configuration Setup...

  • Now edit dnsmasq file by typing " sudo nano /etc/dnsmasq.conf ". (we are going to bridge ethernet and wlan connection).
  • Append the following line into the file and save the file.

domain-needed
bogus-priv

interface=eth0 # change to your chosen interface

dhcp-range=192.168.0.1,192.168.0.100,12h

interface=wlan0

dhcp-range=192.168.1.1,192.168.1.100,24h

  • Disconnect the ethernet cable. ( Internet is no more needed ).
  • Now connect WiFi USB adapter and type " iw list ".
  • The output of this command should have a line bearing " AP MODE ". This assures that your wifi adapter will work as hotspot.
  • Now edit network interfaces file by typing " sudo nano /etc/network/interfaces " and copy the following content and replace the contents that is already present.

auto lo
iface lo inet loopback

auto ppp0

iface ppp0 inet wvdial

auto eth0

iface eth0 inet static

address 192.168.0.1

netmask 255.255.255.0

auto wlan0

iface wlan0 inet static

address 192.168.1.1

netmask 255.255.255.0

hostapd /etc/hostapd/hostapd.conf

  • Now edit the sysctl file by typing " sudo nano /etc/sysctl.conf " and uncomment the following line to enable packet forwarding for IPV4. " net.ipv4.ip_forward=1 "

  • Next we move on to wifi setup.

Step 5: WLAN Setup

  • Most of the work has been done. So now we edit hostapd config file for wifi configuration. by typing " sudo nano /etc/hostapd/hostapd.conf "

interface=wlan0
driver=nl80211 #driver=rtl871xdrv

ssid= YOUR SSID NAME

hw_mode=g

channel=6

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=2

wpa_passphrase= WIFI PASSWORD

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

  • You have to edit SSID name and wifi password as you like.

Step 6: Last Step..

  • type the following lines in terminal

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

  • This makes the firewall to allow packets in and out of the network.
  • Now open /etc/network/interface file and add the following line at the end of it.

pre-up iptables-restore < /etc/iptables.ipv4.nat

  • This completes the router setup. Now reboot the raspberry pi2 and make sure that 3g data card, wifi adapter and ethernet(optional) is connected.
  • Now you can find the WIFI running with the name given by you and by connecting ethernet also you can use the internet. If some problem detected, SSH into the raspberry pi and its ipaddress is 192.168.0.1 and troubleshoot it. Or just reboot itself solves most of the problem you face while running this router.
  • Thank you and enjoy!!!!

Comments

Deviprasath (author)2016-04-22

I wish to make a common comment to all people who are trying to do this project. If you are trying this with raspbian debian 7, No problem, You can use this setup.

But if you are using latest raspbian image, This procedure wont work. In 1st week of may I will edit this procedure to suit for all OS images of Raspberry pi.

marcoboaro (author)2017-08-28

That's a great instructable!

I was just thinking, would it be possible to access WVDIAL through python and use it to limit the data usage or user access?

Deviprasath (author)2016-05-02

I made some changes to suit raspbian latest OS . Hope this setup will help to build wifi-router at an affordable cost.

Di Immortales (author)2016-02-19

Does this cost any additional charges? I.e. data costs

No additional costs... Just like how you use it with laptop or PC

bharatk22 (author)2016-04-22

please tell me is this config setting of cdma data card is universal can i use it with TU500 or zte 8700 evdon modem TU500 modem vid 0x15eb:Pid0x7152 and AC8700 Vid19d2:pid0xfffe please clear it . i was tried to add it but not able to connect.

Deviprasath (author)bharatk222016-04-22

Yeah, this config is universal. But check whether your data card is switching properly to modem or is it staying in memory mode. you can check it with lsusb command. ( Teracom cards had this issue)

Lashway (author)2015-09-05

so, is this an access point for a pre-existing isp, or can I drop comcast and use only this? (Ignoring the loss of data speeds)

Deviprasath (author)Lashway2015-09-05

you can use this for any ISP. this is not restricted to certain ISP. if you are using data cards and trouble connecting other devices to web, this will help.. this is just like 3g routers available on market.. like for example tp-link mr3020.

seamster (author)2015-08-24

Very nice!

Deviprasath (author)seamster2015-08-24

Thank you...

russ_hensel (author)2015-08-24

I do not quite get the 3G part, this looks like wifi. Could you explain?

Deviprasath (author)russ_hensel2015-08-24

We are connecting to the web using a 3g data card which is connected to raspberry pi2 and then we are sharing it through ethernet and Wifi. This is very useful if you have devices like Ipad(wifi only) which cant use sim card.

About This Instructable

9,622views

48favorites

License:

More by Deviprasath:3G Wireless Router Based on Raspberry Pi2
Add instructable to: