Build an anonymous router #linux #Raspberry_Pi @CyberGhost_EN

Oscar Brito

Here in Ireland, more precisely in Cork city, can be very difficult to get a broadband connection.

The house were I'm living has a 3Mb adsl line. Asking 40 euros for a broadband subscription on these conditions is a robbery, so I'm relying on my raspberry connected to 3G by usb tethering.

This is where I start talking about CyberGhost VPNs and anonymous router.
To avoid the QoS and privacy issues of my 3G network operator I'm using a VPN.

An anonymous router will connect every X minutes to a different VPN located in different parts of the globe. Because of this and because the connection will be encrypted through the VPN you will be "anonymous".

By buying a VPN subscription on CyberGhost you can easily build your anonymous router.

OpenVPN

To connect to a VPN using the command line you just need to:

/usr/sbin/openvpn --config /etc/openvpn/cyberghost_de_10_2015.conf --log /var/log/openvpn.log --up /etc/openvpn/up.sh --down /etc/openvpn/down.sh &

/etc/openvpn/up.sh

When the connection is established we should tell iptables to use the NAT table to forward our external network traffic.


#!/bin/sh

# reset iptables
iptables -t nat -D POSTROUTING 1
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

/etc/openvpn/down.sh

When the VPN connection gets disconnected we should reset the iptables NAT.


#!/bin/sh

# reset iptables
iptables -t nat -D POSTROUTING 1
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE

Web Client

Sometimes the VPN connection can be slow. By creating a simple web interface using nodejs I can now switch between VPNs very easily.

Index

When selecting a VPN:

VPN selection

Please let me know if you interested on this. I'll be happy to share on github the source code of this interface.

My next step is automatize the speed testing using speedtest.net NPM module.

Please share, comment and pass the word.

Oscar out!