Setting Up a VPN on Raspberry Pi: How and Why to Build a VPN Server

Don’t trust anyone – build your own VPN server to encrypt web data and avoid prying eyes

While free, unencrypted wireless APs are everywhere, you shouldn’t use them to log into your online banking unless you don’t mind others snooping. So what’s the solution? A, or VPN (virtual private network).

A VPN extends your private network to public places, so even if you’re connected to Starbucks Wi-Fi, your web browsing remains securely encrypted.

VPN,,,VPNVPN。

Wi-Fi。,VPN,($35)。

,VPN。,。,。

,SettingsVPN。,。AboutVPN,。

,,VPN。,。,Eric JodoinVPN,…

,,VPNs。

Raspberry Pi Model B:-。-。

SD card:8GB,。,SDNOOBS。

:。

Open VPN:VPN,。

1) NOOBSRaspbian。""。。

2) SettingsIPAddress。,。,ReadWriteTutorial

3) SSH。SSH,。,Settings。,ReadWriteTutorial

4) 1194IPAddressUDP,,。TCP,,"UDP""TCP",1194。,ReadWriteTutorial

,,VPN。

,,,。,!

First Steps

1) 。(pi)(respberry),。

terminal/PuTTY :


  1. sudo passwd

(),?

2) 。:


  1. sudo aptget update
  2. sudo aptget upgrade

,。

3) (OpenVPN)。:


  1. sudo aptget install openvpn

,。8GBSD,。

4) VPN,Address。。

OpenVPNEasy_RSA,RSA。1977,RSA。,。,。

Easy_RSA,。

,"pi@raspberrypi""root@raspberrypi"。


  1. sudo s

root。root,root,。

,:


  1. cp r /usr/share/doc/openvpn/examples/easyrsa/2.0 /etc/openvpn/easyrsa

,"cp""","r"。:。

/2.0/etcAddress()Address,OpenVPNAddress。


  1. cd /etc/openvpn/easyrsa

5) ,"cd",(change directory),Easy_RSA。,/etc/openvpn/easy-rsa/vars。nano: nano /etc/openvpn/easy-rsa/vars,,:


  1. nano vars

NanoRaspbian,,nano。

, EASY_RSA :


  1. export EASY_RSA="/etc/openvpn/easy-rsa"

,13。

?"?"。,key,easy-rsa。

vars,Email,1024-bit2048-bit。vars,,"2048!"。

,。:


  1. export KEY_SIZE=1024

Control+XLogoutnano。

6) CARoot CA。

,(certificate authority (CA))。。

。,,AddressHTTPS。HTTPS,GeoTrust,。(HeartbleedHTTPS)。

,,OpenVPN,。


  1. cd /etc/openvon/easyrsa

,:

source ./vars → "source"(vars)。

./clean-all → ,。(),。

./build-ca → 。

,,--,,,,Address。,"enter",。:

。“”"Server"。,:


  1. ./buildkeyserver [Server_Name]

,,,:

*Commom Name * 。

A challenge password? ,。

Sign the certificate? [y/n] ,"y"。

3650。,VPN,。

1 out of 1 certificate requests certified, commit? [y/n] ,"y"。

6) Settings。,""。,,,5。,,VPN。


  1. ./buildkeypass UserName

Client1, Client2, Client3…

,!

Enter PEM pass phrase Settings!,。

A challenge password? !

Sign the certificate? [y/n] 。


  1. cd keys
  2. openssl rsa in Client1.key des3 out Client1.3des.key

des3,des33,。OpenSSL ,。。

,。AndroidiOSOpenVPN,,。


  1. Enter pass phrase for Client1.key

,。,。

,:


  1. cd /etc/openvpn/easyrsa/


  1. cd ..

/easy-rsa/。

7) Diffie-Hellman key exange。VPN,。RSA,。


  1. ./builddh

,2048-bit。,。,,1024-bit5。

8) ,OpenVPN(Denial of Service — DoS)。Address,。

HMAC(hash-based message authentication code):


  1. openvpn genkey secret keys/ta.key

9) 。OpenVPN。

Linux,.conf (configuration) OpenVPN,。nano.conf:


  1. nano /etc/openvpn/server.conf

.conf,/etc/openvpn。。Address。,。 Control+X 。

10) 。,。


  1. nano /etc/sysctl.conf

:"IPv4。"("Uncomment the next line to enable packet forwarding for IPv4。")。。

# 。IPv4。,,。

Control+X 。:


  1. sysctl p

sysctl""。-p 。

11) 。,

Raspbian。,OpenVPN,OpenVPN。

,Raspbian。OpenVPN。


  1. nano /etc/firewallopenvpnrules.sh

,:


  1. #!/bin/sh
  2. iptables t nat A POSTROUTING s 10.8.0.0/24 o eth0 j SNAT tosource 192.168.XX.X

IPAddressIPAddress!

: 10.8.0.0 VPNAddress。 "eth0"。 "wlan0", 。 Control+X 。

, /etc/firewall-openvpn-rules.sh,。 700 (、、)。 ,root,,Linux,root。


  1. chmod 700 /etc/firewallOpenVPNrules.sh
  2. chown root /etc/firewallOpenVPNruels.sh

12) OpenVPN,interface,。


  1. nano /etc/network/interfaces

"iface eth0 inet dchp"。 。 ,,,:


  1. iface eth0 inet dhcp
  2. preup /etc/firewallopenvpnrules.sh

Control+X (nano)。

,, :。


  1. sudo reboot

!!vpn,,,6。

 Tors。 Lauren Ordini。 ReadWrite。


via: http://readwrite.com/2014/04/10/raspberry-pi-vpn-tutorial-server-secure-web-browsing

Leave a Comment

Your email address will not be published.