Raspbeery Pi3 with 2 wifi donggle/VPN router

connecting to a WPA WiFi network, your /etc/network/interfaces file will contain something like this:

allow-hotplug wlan0 # detect WiFi adapter
iface wlan0 inet dhcp # connect WiFi with DHCP
wpa-ssid “myhostnetwork” # WPA access point name
wpa-psk “myhostpassword” # WPA access point password

Manually restart WiFi to connect the Raspberry Pi to the Internet.
$ sudo ifdown wlan0
$ sudo ifup wlan0

You can validate that you have a WiFi connection by pinging a website or running the command:

$ ifconfig wlan0

Installing hostapd
$ wget https://github.com/jenssegers/RTL8188-hostapd/archive/v1.1.tar.gz
$ tar -zxvf v1.1.tar.gz
$ cd RTL8188-hostapd-1.1/hostapd
$ make
$ sudo make install

/etc/hostapd/hostapd.conf
interface=wlan1
ssid=mySecureRouter
wpa_passphrase=mySecurePassword

$ sudo service hostapd start
$ sudo update-rc.d hostapd enable

Install DHCP server
$ sudo apt-get install dnsmasq

/etc/dnsmasq.d/dnsmasq.custom.conf
interface=wlan1
dhcp-range=wlan1,192.168.10.10,192.168.10.200,2h
dhcp-option=3,192.168.10.1 # our router
dhcp-option=6,192.168.10.1 # our DNS Server
dhcp-authoritative # force clients to grab a new IP

/etc/resolv.conf
nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.8.4

/etc/network/interfaces
iface wlan1 inet static
address 192.168.10.1
netmask 255.255.255.0

$ sudo ifdown wlan1
$ sudo ifup wlan1
$ sudo service dnsmasq start
$ sudo update-rc.d dnsmasq enable

TOR, or The Onion Router, is an encryption technology that encrypts and distributes your internet data across a network of computers on the way back and forth to a website.
VPNs can be more secure than TOR if you trust your VPN server.

To install TOR,
$ sudo apt-get install tor
$ sudo service tor start
$ sudo update-rc.d tor enable

Installing VPN
$ sudo apt-get install openvpn

Edit /etc/openvpn/client.conf
$ sudo service ntp start
$ sudo update-rc.d ntp enable

$ sudo service openvpn start
$ sudo update-rc.d openvpn enable

Routing
$ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables –t nat –A POSTROUTING –o tun0 -j MASQUERADE
$ sudo iptables –A FORWARD –i wlan1 –o tun0 -j ACCEPT
$ sudo iptables –A FORWARD –i tun0 -o wlan1 –m state –state RELATED,ESTABLISHED –j ACCEPT

persistent the settings
$ sudo sh –c “iptables-save > /etc/iptables.restore”
$ echo “up iptables-restore < /etc/iptables.restore” | sudo tee --append /etc/network/interfaces https://makezine.com/projects/browse-anonymously-with-a-diy-raspberry-pi-vpntor-router/
http://www.dickson.me.uk/2016/06/21/setting-up-a-raspberry-pi-as-a-vpn-router-updated/

发表评论

电子邮件地址不会被公开。 必填项已用*标注