この記事では、Ubuntu 18.04 LTS に OpenVPN をインストールして構成するために必要な手順について説明しました。このチュートリアルを続行する前に、sudo 権限を持つユーザーとしてログインしていることを確認してください。このチュートリアルのすべてのコマンドは、root 以外のユーザーとして実行する必要があります。
仮想プライベート ネットワーク技術により、インターネットのような安全性の低いネットワークを使用して、安全なプライベート ネットワークにアクセスできるようになります。 VPN は通常、組織の物理的に離れた支社を接続するために使用され、あたかも同じ LAN の一部であるかのように見せます (たとえば、異なる都市にある 2 つのオフィス)。接続側間のトラフィックはトンネルを使用して暗号化され、送信データと接続情報自体が保護されます。同じ特性のために、VPN は政府の制限を回避し、インターネット トラフィックを匿名化するためによく使用されます。
Ubuntu 18.04 に OpenVPN をインストール
ステップ 1. まず、Ubuntu サーバーにパッケージをインストールする前に、すべてのシステム パッケージが更新されていることを確認することを常にお勧めします。
sudo apt update sudo apt upgrade
ステップ 2. Ubuntu に OpenVPN をインストールします。
git を使用して openvpn-install リポジトリのクローンを作成します:
sudo apt install git cd ~ git clone https://github.com/Nyr/openvpn-install.git
次に、クローンによって作成されたディレクトリ openvpn-install に移動し、インストーラー スクリプトを実行します。
cd openvpn-install/ openvpn-install.sh chmod +x openvpn-install.sh sudo ./openvpn-install.sh
インストールのデフォルト設定を変更または確認するためのプロンプトがいくつか表示されます:
Welcome to this OpenVPN "road warrior" installer! I need to ask you a few questions before starting the setup. You can leave the default options and just press enter if you are ok with them. First, provide the IPv4 address of the network interface you want OpenVPN listening to. IP address: 192.168.1.2 Which protocol do you want for OpenVPN connections? 1) UDP (recommended) 2) TCP Protocol [1-2]: 2 What port do you want OpenVPN listening to? Port: 443 Which DNS do you want to use with the VPN? 1) Current system resolvers 2) 1.1.1.1 3) Google 4) OpenDNS 5) Verisign DNS [1-5]: 3 Finally, tell me your name for the client certificate. Please, use one word only, no special characters. Client name: client Okay, that was all I needed. We are ready to set up your OpenVPN server now. Press any key to continue... <Enter>
インストールが成功した場合、最後に成功メッセージが表示されます:
sing configuration from ./openssl-easyrsa.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'client' Certificate is to be certified until Feb 4 07:53:27 2020 GMT (3650 days) Write out database with 1 new entries Data Base Updated Using configuration from ./openssl-easyrsa.cnf An updated CRL has been created. CRL file: /etc/openvpn/easy-rsa/pki/crl.pem 346 Finished! Your client configuration is available at: /root/client.ovpn If you want to add more clients, you simply need to run this script again!
メインの OpenVPN サーバー構成ファイルは、/etc/openvpn/server.conf です。 好みに合わせて自由に調整および微調整できます:
### cat /etc/openvpn/server.conf port 443 proto tcp dev tun sndbuf 0 rcvbuf 0 ca ca.crt cert server.crt key server.key dh dh.pem auth SHA512 tls-auth ta.key 0 topology subnet server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" keepalive 10 120 cipher AES-256-CBC comp-lzo user nobody group nogroup persist-key persist-tun status openvpn-status.log verb 3 crl-verify crl.pem
ステップ 3. OpenVPN ユーザー プロファイルを生成します。
ユーザーが使用する VPN プロファイルを生成する必要があります。これには、インストールに使用したのと同じスクリプトが使用されます:
# ./openvpn-install.sh Looks like OpenVPN is already installed. What do you want to do? 1) Add a new user 2) Revoke an existing user 3) Remove OpenVPN 4) Exit Select an option [1-4]: 1 Tell me a name for the client certificate. Please, use one word only, no special characters. Client name: ramona Generating a 2048 bit RSA private key ...+++ .............................................................................................................................+++ writing new private key to '/etc/openvpn/easy-rsa/pki/private/ramona.key.bmwe46' ----- Using configuration from ./openssl-easyrsa.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'ramona' Certificate is to be certified until Feb 4 08:10:32 2020 GMT (3650 days) Write out database with 1 new entries Data Base Updated Client ramona added, configuration is available at: /root/ramona.ovpn
出力から、私のプロファイルの場所を確認できます。/root/ramona.ovpn このプロファイルをユーザーにコピーする必要があります。関連する秘密鍵の場所も提供されます /etc/openvpn/easy-rsa/pki/private/ramona.key.bmwe46.
ステップ 4. クライアントから OpenVPN サーバーに接続します。
最後の手順として、選択した VPN クライアントを使用して、オペレーティング システムで OpenVPN クライアントを構成できます。公式の OpenVPN クライアントを使用したい場合は、ダウンロード ページに移動し、最新のリリースを入手してからインストールしてください。
Ubuntu 18.04 に OpenVPN をインストールするために必要なことはこれだけです。この簡単なヒントがお役に立てば幸いです。質問や提案がある場合は、下にコメントを残してください。