6

I have a Model B which is hooked up to my network via ethernet.

It also has a wireless USB dongle plugged into it which is currently not in use.

I have Tunnelbear's unlimited VPN (grizzly) and wondered whether I could turn my raspberry pi into my own Tunnelbear access point?

So basically my Pi could share its ethernet connection over wifi but share a Tunnelbear VPN instead. So for my devices which do not support Tunnelbear's client, I could have a Tunnelbear wifi access point I could connect to like a normal wifi access point.

Is this possible? Does anyone know of a way I could possibly do this as I would love to get some of my unsupported devices using my paid for VPN.

UPDATE: Tunnelbear do provide some OpenVPN OVPN files for using their VPN service with linux.

Jamesking56
  • 273
  • 2
  • 6
  • 15

3 Answers3

2

I am not familiar with Tunnelbear, but I assume once you have set it up (should be easy if they have OpenVPN support, besides, you did not ask how to set up Tunnelbear, you asked how to share it. Add a comment if you need to know more about OpenVPN), you will have a network device (let's call it tun0) with an IP address in the VPN, and your wifi dongle (let's call it eth1).

First give your WiFi a fixed IP:

sudo ip addr add 192.168.0.1/24 dev eth1

Then configure NAT:

sudo iptables -A FORWARD -o tun0 -i eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -t nat -F POSTROUTING sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Save the iptables:

sudo iptables-save | sudo tee /etc/iptables.sav

Edit /etc/rc.local and add the following line before the "exit 0" line:

iptables-restore < /etc/iptables.sav

Enable routing

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Edit /etc/sysctl.conf:

net.ipv4.ip_forward=1

On your clients you need to add

sudo ip route add default via 192.168.0.1 and give it an IP address in the 192.168.0.0/24-range.

Amedee Van Gasse
  • 564
  • 4
  • 16
2

You just need to turn your Raspberry Pi into a router, then the traffic to Internet will be routed by your Raspberry Pi via the VPN.

You need to enable ip_fowarding in your rPi:

echo "1" > /proc/sys/net/ipv4/ip_forward 

and NAT the traffic coming out of your rPi to the Internet, so if it is your eth0 connected to Internet, using iptables:

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

Then you just need to configure your network clients to use you rPi as router, ie: default gateway.

On Linux:

ip route del default;ip route add default via <raspberrypi ip>

More over, you can setup a DHCP server on your Raspberry Pi to configure the hosts over your wifi network and set the rPi address as default gateway, etc.

For seeting up your Raspberry Pi as a Wireles Access Point see here:

http://www.pi-point.co.uk/

Matías
  • 189
  • 4
0

You could try following this tutorial which uses PIA for the VPN access but all you would need to do is change the section in the tutorial which refers to the PIA setup to Tunnel Bear.

https://www.novaspirit.com/2017/06/22/raspberry-pi-vpn-router-w-pia/

This setup uses just the one network interface and works quite well.

Shane
  • 1
  • 2