Many moons ago, I wrote a tutorial on how to set up an internet gateway on a Banana Pi, complete with DHCP, DNS, VPN, firewall and ad-blocking. It works well, I still use one today, and have even taken it with me on a few long backpacking trips. However, I worry about it being a bit fragile, and fear the day when an over-zealous customs officer decides it looks like something that could trigger a bomb , so I was overjoyed when I finally found my holy grail: something that does all of the above, in the form factor of a USB thumb drive.
GL-iNet's GL-USB-150 costs around USD 30, and comes with almost everything I need to get online when I'm on the road. This tutorial will be much shorter than the previous one, because nearly everything is already set up and ready to go
Plug it in, give it 30 or 40 seconds to start up, then open a browser and go to http://192.168.8.1. To login, the default password is goodlife; once you're in, change this under More Settings/Admin Password.
It runs a DHCP server, and your computer will have already been assigned an IP address in the 192.168.8.xxx range.
Open another browser window, and confirm that you're online.
Configuring the VPN
Go to the Management tab in the VPN/OpenVPN Client page, and upload your VPN configurations. This will typically be a ZIP of a bunch of .ovpn files, but if you have them, you will also need to include the .crt and/or .pem files.
Unfortunately, the stock firmware has a bug that prevents the ZIP file from being processed correctly, so you will need to upgrade the firmware first. Get the latest version from hereVersion 3.026 worked for me., then install it via the Upgrade page.
Once the VPN configurations have been installed, you will be able to select which one to use from the VPN/OpenVPN Client page. Check your IP address to confirm that you are going through the VPN.
To install additional software, go to the More Settings/Advanced page, and in the new browser window that opens, go to System/Software and update the package listsThis doesn't seem to persist after a reboot, so you have to remember to do this every time .
I installed the following packages:
- openssh-sftp-server (so that I can scp files in and out)
- openssh-client (for a version of ssh that allows forwarding)
- coreutils (for GNU tools)
- bind-dig (for dig)
- mtr (a handy network monitoring tool)
To change your default shell to bash, update /etc/passwd.
The only down-side to this device: while you can just about install a minimal version of Python, the disk is so small, there won't be any room for anything else
The only thing missing from this device is an ad-blocker. Since it uses dnsmasq for DNS, rather than bind as the Banana Pi does, the process is slightly different, but not much. Here's the script that I use:
# This script downloads blacklisted ad servers and updates dnsmasq to block them. # # The following line needs to be added to /etc/dnsmasq.conf: # conf-file=/root/dns-blacklist BLACKLIST_URL="http://pgl.yoyo.org/as/serverlist.php?hostformat=dnsmasq&mimetype=plaintext" BLACKLIST_FNAME=/root/dns-blacklist echo "Downloading the DNS blacklist..." TMP_FNAME=/tmp/dns-blacklist wget -O "$TMP_FNAME" "$BLACKLIST_URL" if [ $? -ne 0 ] ; then exit 1 ; fi echo # fixup the entries so that they return "NX Domain" echo "Updating the DNS blacklist..." sed -i 's/address/server/g;s/127.0.0.1//g' "$TMP_FNAME" echo # install the new DNS blacklist echo "Installing the DNS blacklist..." echo " $TMP_FNAME => $BLACKLIST_FNAME" mv "$TMP_FNAME" "$BLACKLIST_FNAME" echo "Restarting dnsmasq..." /etc/init.d/dnsmasq restart echo echo "All done."
The DNS blacklist is downloaded to a temp file, fixed up and then transferred to /root/dns-blacklist. You will need to tell dnsmasq to load this file by adding the following line to /etc/dnsmasq.conf:
This script can be configured to run periodically, or just run it manually every now and then.
There doesn't seem to be any way to shut down the device cleanly. I'm guessing it's been designed so that people can just pull the thing out of the USB port, but this really irks the sysadmin in me , so to shutdown cleanly, type the following in the console:
The green LED light stays on, but the device will shutdown.