GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu20.04LTSにOpenVPNサーバーをインストールする方法

このチュートリアルでは、OpenVPNサーバーをUbuntu 20.04 LTSにインストールする方法を紹介します。知らなかった方のために説明すると、OpenVPNは堅牢で柔軟性の高いオープンソースVPNソフトウェアです。 OpenSSLライブラリのすべての暗号化、認証、認証機能を使用して、単一のUDPまたはTCPポートを介してIPネットワークを安全にトンネリングします。

この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、サイトを独自のVPSでホストしていることを前提としています。インストールは非常に簡単で、ルートアカウントで実行されていますが、そうでない場合は、'sudoを追加する必要があります。 ‘ルート権限を取得するコマンドに。 Ubuntu 20.04(Focal Fossa)サーバーにOpenVPNを段階的にインストールする方法を紹介します。

前提条件

  • 次のオペレーティングシステムのいずれかを実行しているサーバー:Ubuntu 20.04、18.04、およびLinuxMintやエレメンタリーOSなどの他のDebianベースのディストリビューション。
  • 潜在的な問題を防ぐために、OSの新規インストールを使用することをお勧めします。
  • non-root sudo user またはroot userへのアクセス 。 non-root sudo userとして行動することをお勧めします ただし、ルートとして機能するときに注意しないと、システムに害を及ぼす可能性があるためです。

Ubuntu 20.04 LTSFocalFossaにOpenVPNサーバーをインストールする

手順1.まず、次のaptを実行して、すべてのシステムパッケージが最新であることを確認します。 ターミナルのコマンド。

sudo apt update
sudo apt upgrade
ステップ2.Ubuntu20.04にOpenVPNをインストールします。

OpenVPNインストールリポジトリのクローンを作成します。したがって、インストールは以下のコマンドを実行するのと同じくらい簡単です。

wget https://git.io/vpn -O openvpn-install.sh && bash 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.77.21

Which protocol do you want for OpenVPN connections?
1) UDP (recommended)
2) TCP
Protocol [1-2]: 1

What port do you want OpenVPN listening to?
Port: 1194

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]: 1

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...

メインのOpenVPNサーバー構成ファイルは/etc/openvpn/server.confです。 自由に調整して、好みに合わせて調整できます:

$ cat  /etc/openvpn/server.conf 
port 1194
proto udp
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ユーザープロファイル(.ovpnファイル)を生成する

ユーザーが使用する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: meilana.maria
Generating a 2048 bit RSA private key
...+++
.............................................................................................................................+++
writing new private key to '/etc/openvpn/easy-rsa/pki/private/meilana.maria.key.8dsBMWTWPe'
-----
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:'meilana.maria'
Certificate is to be certified until May  4 16:16:32 2028 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated

Client josphat.mutai added, configuration is available at: /root/meilana.maria.ovpn

ステップ4.クライアントからOpenVPNサーバーに接続します。

選択したVPNクライアントを使用して、オペレーティングシステムでOpenVPNクライアントを構成できます。公式OpenVPNクライアントを使用する場合は、ダウンロードにアクセスしてください。ページ。

おめでとうございます!OpenVPNが正常にインストールされました。このチュートリアルを使用してUbuntu 20.04 LTS(Focal Fossa)システムにOpenVPNサーバーをインストールしていただきありがとうございます。追加のヘルプや役立つ情報については、 OpenVPNの公式ウェブサイト。


Ubuntu
  1. Ubuntu18.04LTSにMinecraftサーバーをインストールする方法

  2. Ubuntu20.04LTSにDiscourseをインストールする方法

  3. Ubuntu18.04LTSにGlassFishをインストールする方法

  1. Ubuntu Server18.04LTSのインストール方法

  2. Ubuntu18.04LTSサーバーにDockerをインストールする方法

  3. Ubuntu18.04にOpenVPNをインストールする方法

  1. Ubuntu20.04LTSサーバーをインストールする方法

  2. Ubuntu18.04LTSサーバーにDropboxをインストールする方法

  3. Ubuntu22.04LTSにWebfsサーバーをインストールする方法