LoginSignup
15

More than 1 year has passed since last update.

posted at

updated at

VPSにAlgo VPNを構築 (Ubuntu サーバー)

(2019年6月2日更新)

概要

Ubuntu 18.04がインストールされたVPSにAlgo VPNを構築しWindows 10からアクセス。

Algo VPNとは

https://github.com/trailofbits/algo
オープンソースVPNサーバです。
OpenVPNとの一番の違いはWindows10 やアップル製品(MacOS、iOs)でクライアントソフトが必要ないということだと思います。
*最新版ではアップル製品、AndroidはWireGuardをクライアントとして利用するようになりました。

注意

Algo VPNはサーバーをVPNサーバー専用として利用することを想定しています。インストールするとiptableが書き換えられてしまうので、すでに他の用途に利用しているサーバーにはインストールしないでください。
VPSの試用期間や仮想環境で試してから利用することをおすすめします。

実際に構築してみた

依存パッケージのインストール

sudo apt update -y
sudo apt upgrade -y
sudo apt install -y build-essential  \
  libssl-dev \
  libffi-dev \
  python-dev \
  python-pip \
  python-setuptools \
  python-virtualenv -y

Algo VPNのインストール準備

git clone https://github.com/trailofbits/algo
cd algo
python -m virtualenv env
source env/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt

VPNを利用するユーザーを設定、ログを無効にする

nano config.cfg

users: の後にVPNを利用するユーザー名を記述します。

users:
  - hogehoge
  - nanashi
  - user

ログを無効にする場合、strongswan_log_levelを-1に変更します

# StrongSwan log level
# https://wiki.strongswan.org/projects/strongswan/wiki/LoggerConfiguration
strongswan_log_level: -1

Algo VPNをインストール

./algo

このコマンドを実行するとどの環境にインストールするか?という画面になります。

What provider would you like to use?
    1. DigitalOcean
    2. Amazon Lightsail
    3. Amazon EC2
    4. Vultr
    5. Microsoft Azure
    6. Google Compute Engine
    7. Scaleway
    8. OpenStack (DreamCompute optimised)
    9. Install to existing Ubuntu 18.04 or 19.04 server (Advanced)

Enter the number of your desired provider
:

ここではUbuntu 18.04を使用しているので、9を入力しエンターキーを押します。
インストールが始まるといくつかの質問をされます。基本的にy(Yes)で問題ないはずです。

macOS/iOSでモバイルデータ通信時にVPNオンデマンドを有効にするか?
Do you want macOS/iOS clients to enable "VPN On Demand" when connected to cellular networks?

macOS/iOSでWi-Fi通信時にVPNオンデマンドを有効にするか?
Do you want macOS/iOS clients to enable "VPN On Demand" when connected to Wi-Fi?

VPNを使用しない信頼できるWi-fiネットワーク名を入力
List the names of trusted Wi-Fi networks (if any) that macOS/iOS clients exclude from using the VPN
(e.g., your home network. Comma-separated value, e.g., HomeNet,OfficeWifi,AlgoWiFi)

広告をブロックするDNSリゾルバをインストールするか?
Do you want to install a DNS resolver on this VPN server, to block ads while surfing?

ユーザー毎にSSHトンネルに使うアカウントを作成するか?
Do you want each user to have their own account for SSH tunneling?

このVPNをWindows 10とLinuxデスクトップクライアントへ対応させるか?
Do you want the VPN to support Windows 10 or Linux Desktop clients? (enables compatible ciphers and key exchange, less secure)
Windows 10で使用するので必ずYesを選択。

CA鍵を保持するか? (後でユーザーを追加するために必要だが、保持すると安全性が低くなる)
Do you want to retain the CA key? (required to add users in the future, but less secure)

サーバーのIPアドレスを入力
Enter the IP address of your server: (or use localhost for local installation):
今はローカルにインストールしているのでデフォルトのlocalhostのままでいいです。

What user should we use to login on the server? (note: passwordless login required, or ignore if you're deploying to localhost)
空欄で大丈夫です。

サーバーのパブリックIPを入力
Enter the public IP address of your server: (IMPORTANT! This IP is used to verify the certificate)
重要。 必ず入力してください。

インストールが終わるまで少し待ってください。

                      Congratulations!                            
                   Your Algo server is running.                     
   Config files and certificates are in the ./configs/ directory.
             Go to https://whoer.net/ after connecting  
       and ensure that all your traffic passes through the VPN.  
                 Local DNS resolver 172.16.0.1  

  The p12 and SSH keys password for new users is パスワード1
   The CA key password is パスワード2      

このような画面が出ればインストール成功です。
2つのパスワードは必ず保存しておいてください。

各デバイスの設定ファイルがconfigs/サーバーのIPアドレスフォルダに生成されています。

Windows 10の設定

ipsec/windows/ユーザー名.ps1ファイルをサーバーからダウンロードします。
そしてPowerShellを管理者権限で起動し次のコマンドを実行しインストール終了時に表示されたp12パスワードを入力。

powershell -ExecutionPolicy ByPass -File windows_ユーザー名.ps1 -Add

タスクバーのネットワークボタンからVPN接続をして利用してください。

アンイストールする場合次のコマンドを実行してください。

powershell -ExecutionPolicy ByPass -File windows_ユーザー名.ps1 -Remove

WireGuardの設定

wireguard/ユーザー名.confを使い設定をインポートするかwireguard/ユーザー名.pngをWireGuardでスキャンして設定します。

ユーザの追加

インストール時にCA鍵を保持するを選択した場合は次の手順で後からユーザーを追加することができます。

nano config.cfg #ユーザー名を編集
source env/bin/activate
./algo update-users

コマンドを実行するとCA鍵が求められるので入力します。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
15