Do you write a password on a sheet of paper and paste it on your forehead? Definitely not. Connecting to a public WiFi network is like doing something stupid. However, you have no other option if you are on the road and still want to remain connected. VPN can help you be safe, but each device must connect separately, unless you use travel router as an intermediary.

If you don't have one of the best travel routers, don't worry. Readers can build such a router with Raspberry Pi. Raspberry Pi is the perfect choice for traveling homemade VPN routers. Read the following guide to learn how to build a secured travel router with VPN.

Create a secure travel router from Raspberry Pi

  1. Things to prepare
  2. Steps to turn Raspberry Pi into travel router with VPN
    1. Step 1: Install OpenWRT
    2. Step 2: Initial configuration
    3. Step 3: Update and install the package
    4. Step 4: Set up WiFi Access Point (WiFi access point)
    5. Step 5: Connect with VPN and final changes
    6. Step 6: Register the device on public WiFi

Things to prepare

To start building your Raspberry Pi VPN router, you will need:

  1. Raspberry Pi (priority Pi 3 or Raspberry Pi Zero W) has a protective case (case).
  2. A USB WiFi adapter (or two adapters if using the old Raspberry Pi).
  3. MicroSD memory card has a minimum storage capacity of 8GB.
  4. SD card reader.
  5. A power source
  6. PC has installed SSH client
  7. Sign up for a VPN that supports OpenVPN

Pi models can be used without WiFi integration, but you will need two USB WiFi adapters or an adapter capable of running both managed / access point mode and client mode. (client mode).

You need to install OpenWRT into the SD card to turn it into a complete router. You can use another Linux distribution if you like, but OpenWRT provides a handy web interface for remote configuration.

If you use Windows, you also need to install PuTTY for Windows or SSH client before starting.

Steps to turn Raspberry Pi into travel router with VPN

Step 1: Install OpenWRT

How to turn Raspberry Pi into travel router with VPN Picture 1

First, download the OpenWRT firmware for the Raspberry Pi model. You can find the latest images from the OpenWRT wiki page.

Unzip the downloaded file with 7zip or another suitable file extraction software, then flash the IMG file to the card with Etcher.

This tool will automatically detect SD card. You just need to select your image file, select the correct drive and then click Flash.

Once completed, place the microSD memory card into the Raspberry Pi and let it boot.

Step 2: Initial configuration

By default, OpenWRT has a static IP address 192.168.1.1 by default (this is the default IP port for many routers). You need to change this to prevent the risk of conflict. Connect Pi to PC with Ethernet cable. You may need to set a static IP on the PC first.

Instead of processing the LuCI configuration, OpenWRT web interface, you should do it manually to ensure the configuration is set correctly. Load PuTTY or SSH client and connect to 192.168.1.1 first by root user name.

You will receive an initial security warning on the first connection. Just click Yes and continue. Setting a password at this stage is not a bad idea. Do it by typing passwd in the terminal window.

Configure network and firewall settings

Users need to edit two files, / etc / config / network and / etc / config / firewall, before continuing. Start by typing the following command to edit the file:

 vim /etc/config/network 

Next, press I to edit the text and add the following items:

 config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config interface 'lan' option type 'bridge' option ifname 'eth0' option force_link '1' option proto 'static' option ipaddr '192.168.38.1' option netmask '255.255.255.0' option ip6assign '60' config interface 'wwan' option proto 'dhcp' option peerdns '0' option dns '8.8.8.8 8.8.4.4' ## Google DNS servers config interface 'vpnclient' option ifname 'tun0' option proto 'none' 

When finished, press the Esc key and type : qw to save and exit. Then switch to the firewall configuration file:

 vim /etc/config/firewall 

Click I to edit, then find (or add) a region for the WAN as follows:

 config zone option name wan option network 'wan wan6 wwan' option input ACCEPT option output ACCEPT option forward REJECT option masq 1 option mtu_fix 1 

Enter reboot and wait for the Raspberry Pi to restart with the new IP address: 192.168.38.1.

Step 3: Update and install the package

Next, update OpenWRT. To do that, you have to borrow the internal WiFi function of Pi and initial setup so that it connects to the current WiFi network. You may need to change a static IP address to 192.168.38.2 or a similar address within that range to allow connection.

After connecting, enter the IP address of the Raspberry Pi into the browser to access the OpenWRT administration console. Use the username and password to get access, then go to Network> Wireless . Currently you only see a WiFi device, so click Scan to find WiFi network, then click Join Network when you find the network.

Need to enter the WiFi password in WPA Passphrase, before clicking Submit.

Now, you will see connection settings for your WiFi. Go to the Advanced Settings section and set the Country Code to match the current location.

Reconnect to Pi with a new IP address via SSH (accept RSA security key warning). You must also update your device first by typing:

 opkg update 

Follow and click on Y when prompted.

Install the WiFi USB driver

After installing all updates, install all necessary drivers for the USB WiFi adapter. This is required to connect to WiFi hotspots (WiFi access points) on the move. Need to install the necessary tools for VPN connections using OpenVPN, like nano, a terminal file editor is easier to use.

In the example, use the WiFi adapter chipset RT2870, so the following commands will also work if you have the same adapter:

 opkg install kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb kmod-usb-core kmod-usb-uhci kmod-usb-ohci kmod-usb2 usbutils openvpn-openssl luci-app-openvpn nano ifconfig wlan1 up reboot 

If there is no WiFi adapter chipset RT2870 or not sure what your adapter is, plug in the WiFi adapter and enter the following information into the SSH terminal:

 opkg install kmod-usb-core kmod-usb-uhci kmod-usb-ohci kmod-usb2 usbutils lsusb 

When the files are installed, the list of connected devices is displayed. Find any adapter related devices and installation instructions for that device.

How to turn Raspberry Pi into travel router with VPN Picture 2

Step 4: Set up WiFi Access Point (WiFi access point)

If the USB WiFi adapter is connected, it is possible to set up a WiFi connection. Go back to the LuCI control panel, in the Wireless section , delete both network connections. Radio0 device is integrated WiFi and radio1 is USB WiFi adapter.

Set up WiFi integration by clicking Add. Ensure the following:

  1. Mode is set to Access Point
  2. ESSID is set to the selected network name, the default is OpenWRT
  3. Network is set to Lan
  4. In Wireless Security, Encryption is set to WPA2-PSK
  5. The key is set to the appropriate password

When done, press Save and then return to the Wireless menu . Follow the previous instructions for the initial connection to set the radio1 device (USB WiFi adapter) to the current network. This is also when users will need to scan and change the network when in a new location.

How to turn Raspberry Pi into travel router with VPN Picture 3

Now, there will be two running WiFi connections, a connection that acts as an access point for WiFi devices and a connection that acts as an Internet connection for the device to the current WiFi network. Try connecting to Pi with your smartphone or laptop to see if it works.

If it works, disconnect Pi from connecting to the PC with an Ethernet cable.

Step 5: Connect with VPN and final changes

You need an OpenVPN configuration file (OVPN) to connect Pi to the selected provider and VPN server. If you already have this file, upload it to Pi using the SCP client as WinSCP when connecting to the admin username and password.

Rename the file to vpnclient.ovpn and upload it to the / etc / openvpn directory. Complete the instructions on the OpenWRT website to set up Pi for VPN connections. The only minor change will be in part 4 for the VPN client profile setting. Here, there is no need to use the original cat tool to insert the vpnclient.ovpn file, as it is already available.

As soon as this is done, the VPN connection will automatically activate. Check if the IP address has changed. If not, restart Pi and check if the connection is working, by going to LuCI's OpenVPN section, and looking in the Services section at the top of the control panel. If the connection is active, vpnclient will be listed in Yes status in the Started column .

How to turn Raspberry Pi into travel router with VPN Picture 4

Step 6: Register the device on public WiFi

Pi is almost ready at this stage, but if you have ever connected to a public WiFi network, users know that it will need to authenticate using the captive portal (captive portal is a website accessed by submission). Web browsing, displayed for new users connected in WiFi networks, before they are granted wider access to network resources), to pay or register equipment. Since Pi is currently set to automatically connect via VPN, these ports will usually be blocked.

To solve this problem, set the USB WiFi adapter to match the device's MAC address used to connect and authenticate with the public WiFi network first, such as a smartphone. Next, enter:

 nano /etc/init.d/wan-changer 

In the edit window, add the following (replace XX with MAC address) and press Ctrl + X , then Y to save.

 #!/bin/sh /etc/rc.common START=10 start() { uci set wireless.@wifi-iface[1].macaddr='XX:XX:XX:XX:XX:XX' uci commit network } 

Finally, run the following commands to set the script to run automatically when Pi starts:

 chmod +x /etc/init.d/wan-changer /etc/init.d/wan-changer enable 

Restart to check if everything works well. Check to see if there is any DNS leak to make sure the VPN connection is working correctly. Most VPN providers have a help tool to do this.

Raspberry Pi will now be set up and ready to function as a VPN router, meaning you can safely surf the web in any hotel or cafe that visits. Thanks to the LuCI control panel, you can easily connect to any new WiFi network through your web browser.

See the list of the best VPN services of TipsMake.com to find a VPN service that suits your needs.

Hope you are succesful.

4 ★ | 443 Vote | 👨 98480 Views

Above is an article about: "How to turn Raspberry Pi into travel router with VPN". Hope this article is useful to you. Don't forget to rate the article, like and share this article with your friends and relatives. Good luck!

« PREV POST
NEXT POST »