Introduction: 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.
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.
interface=eth0 # change to your chosen interface
- 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.
iface lo inet loopback
iface ppp0 inet wvdial
iface eth0 inet static
iface wlan0 inet static
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 "
ssid= YOUR SSID NAME
wpa_passphrase= WIFI PASSWORD
- 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!!!!
We have a be nice policy.
Please be positive and constructive.