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.

3 Answers 3

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/

2
  • Yeah that's exactly what I already wrote one hour earlier. The only new information is setting up as a wireless access point, which was an additional question after I gave my answer. Stackoverflow is not a link dump, it would be helpfullif you included the gist of it, in case the link gets stale. Dec 9, 2014 at 12:40
  • 1
    I just added the link on my edit. But I agree with you, I was actually going to post it but I rather first test it on my raspberry pi. But for that Jamesking56 will have to wait because I do not have time for this untill the weekend. I guess it was better to post the link so he can try that out. I'll edit my post on the weekend, though.
    – Matías
    Dec 9, 2014 at 14:31
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.

2
  • Yeah I am completely new to OpenVPN, all I have is OVPN files supplied to me by Tunnelbear Dec 5, 2014 at 15:58
  • Also how do I then setup the SSID, WPA key and DHCP Server for this? Dec 5, 2014 at 16:05
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.