This will set up a passthrough between the eth0
interface and the wan0
interface, with a VPN connection in-between.
You can then connect a machine to the ethernet port of the raspberrypi, and that machines network traffic will pass through the vpn tunnel on the raspberrypi.
The device connected to the ethernet plug of the PI should be set up with:
IP: 192.168.0.2
Mask: 255.255.255.0
Gateway: 192.168.0.1
$ sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "<insert_wpa_id>"
wpa-psk "<insert_wpa_password>"
wireless-power off
$ sudo ifdown wlan0
$ sudo ifup wlan0
$ sudo apt-get install openvpn
Configure the VPN with your providers settings.
$ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
$ sudo nano /etc/sysctl.conf
In this file, uncomment the line:
net.ipv4.ip_forward=1
$ sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
$ sudo iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
$ sudo iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo apt-get install iptables-persistent
$ sudo sh -c "iptables-save > /etc/iptables/rules.v4"