GithubHelp home page GithubHelp logo

bigwall's Introduction

Chapter 1 Server Side Configuration

Create your own VPS from Linode, GCP, Vultr, Digital Ocean or Azure. I haven't tried AWS.

Choose the operating system Ubuntu.

This guide help you setup two ways to safe surf the internet, proxy and VPN.

Both ways are good.

The proxy way gives you more options than VPN. You can make the proxy system-wide or just for individual app.

Overview

picture

  • All network traffic through the stunnel (a SSL proxy).
  • Provide client side applications multiple choice to access the internet via HTTP(S) proxy, SOCKS5 proxy or VPN.

Install Software

  1. sudo apt install squid3 stunnel4 openvpn easy-rsa
  2. sudo -s

Configure Stunnel

  1. cd /etc/stunnel
  2. openssl genrsa -out key.pem 2048
  3. openssl req -new -x509 -key key.pem -out cert.pem -days 3650

Set Common Name to your vps public IP or domain name

  1. cat key.pem cert.pem >> stunnel.pem
  2. openssl pkcs12 -export -out stunnel.p12 -inkey key.pem -in cert.pem
  3. vi stunnel.conf

Copy the content of stunnel-server.conf

  1. vi /etc/default/stunnel4

change the enabled line to 1: ENABLED=1

  1. service stunnel4 restart
  2. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  3. iptables -A INPUT -p tcp --dport 7777 -j ACCEPT
  4. iptables -A INPUT -p tcp --dport 7788 -j ACCEPT

Configure OpenVPN

  1. cd /etc/openvpn
  2. make-cadir easy-rsa
  3. cd easy-rsa
  4. cp openssl-1.0.0.cnf openssl.cnf
  5. source ./vars
  6. ./clean-all
  7. ./build-ca
  8. ./build-key-server server

Set Common Name to your vps public IP or domain name

  1. ./build-key client
  2. ./build-dh
  3. cd ..
  4. vi server.conf

Copy the content of openvpn-server.conf, replace <server-address> with your VPS IP address.

  1. service openvpn restart
  2. vi /etc/sysctl.conf

Uncomment the line: net.ipv4.ip_forward=1

  1. sysctl -p
  2. ifconfig

Check network interface name. Is it eth0?

  1. iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  2. apt install iptables-persistent

Reboot

Each time after the system restarted, if the iptables-persistent doesn't work, execute below commands manually:

  1. sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  2. sudo iptables -A INPUT -p tcp --dport 7777 -j ACCEPT
  3. sudo iptables -A INPUT -p tcp --dport 7788 -j ACCEPT
  4. sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

Use commands sudo iptables -L and sudo iptables -t nat -L to see the firewall rules.


Chapter 2 Client Side Configuration

Stunnel is required. OpenVPN is optional.

Install Stunnel

Configure Stunnel

  • Ubuntu

    1. Copy /etc/stunnel/stunnel.pem from your VPS to the same folder on your client.
    2. Download stunnel-client.conf from this github repository.
    3. Copy it to /etc/stunnel folder.
    4. Modify /etc/default/stunnel4

    set ENABLED=1

    1. Restart stunnel sudo service stunnel4 restart
  • Mac

    1. Copy /etc/stunnel/stunnel.pem from your VPS to /usr/local/etc/stunnel on your Mac.
    2. Download stunnel-client.conf from this github repository.
    3. Copy it to /usr/local/etc/stunnel folder.

    To start the stunnel, You need to open a terminal and run command stunnel.

  • Windows

    1. Copy /etc/stunnel/stunnel.pem from your VPS to C:\Program Files (x86)\stunnel\config on your Windows.
    2. Download stunnel-client.conf from this github repository.
    3. Copy it to C:\Program Files (x86)\stunnel\config folder.
  • Android

    1. The PKCS12 file is the stunnel.p12 generated from upon step 7.

Install OpenVPN

Configure OpenVPN

  • Ubuntu

    1. Download openvpn-client.ovpn from this github repository.
    2. Edit the file.
      • Replace <server-address> with your VPS address.
      • Follow the comments in the content, copy/paste the content of the CA certificate, client certificate and key content from your VPS.
    3. For Ubuntu 1804, you need to fix the DNS leak.
      • sudo apt install openvpn-systemd-resolved
      • Copy below block to openvpn-client.ovpn
                script-security 2
                up /etc/openvpn/update-systemd-resolved
                down /etc/openvpn/update-systemd-resolved
                down-pre
                dhcp-option DNSSEC allow-downgrade
                dhcp-option DOMAIN_ROUTE .

To start the openvpn, run sudo openvpn --config <path>/openvpn-client.ovpn

  • Mac

    1. Download openvpn-client.ovpn from this github repository.
    2. Edit the file.
      • Replace <server-address> with your VPS address.
      • Follow the comments in the content, copy/paste the content of the CA certificate, client certificate and key content from your VPS.
    3. Launch tunnelblick, import openvpn-client.ovpn
  • Windows

    1. Download openvpn-client.ovpn from this github repository.
    2. Edit the file.
      • Replace <server-address> with your VPS address.
      • Follow the comments in the content, copy/paste the content of the CA certificate, client certificate and key content from your VPS.
    3. Launch OpenVPN GUI, import openvpn-client.ovpn
  • Android

    1. You must exclude the SSLDroid bypass the VPN in the OpenVPN settings. It is because the OpenVPN traffic need to pass via the stunnel.

bigwall's People

Contributors

howard-tian avatar tianhu avatar

Stargazers

 avatar

Forkers

essoojay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.