LoginSignup
9
3

[オンプレ]SoftEther VPN ServerをUbuntuにインストール

Last updated at Posted at 2021-10-07

1. はじめに

この記事は、Ubuntuを小型PC「BMAX」にインストールする方法の備忘録です。

2. Ubuntu Server 20.04 LTSをインストール

Rufusを使ってUSBメモリにUbuntuのISOイメージを書き込む。
Escキーを連打してBMAXのBIOSに入りブート順序を変更する。
Ubuntuをインストールする際にSSHも同時にインストールする。

3. パッケージの更新

sudo su
apt update
apt upgrade -y

4. ファイアウォールの許可設定

ufw allow ssh, 443, 500, 4500, 5555
ufw enable

5. SoftEther VPN Serverをインストール

必要パッケージをインストールする。

apt install -y gcc make

作業用ディレクトリに移動する。

mkdir tmp
cd tmp

最新版をダウンロード、解凍する。
https://www.softether-download.com/ja.aspx?product=softether

wget https://~.tar.gz
tar -xzvf softether~.tar.gz

ビルドする。

cd vpnserver
make

ディレクトリを移動、パーミッションを設定する。

cd ..
mv vpnserver /usr/local
cd /usr/local/vpnserver
chmod 600 *
chmod 700 vpncmd vpnserver

サービスに登録する。

nano /etc/systemd/system/vpnserver.service

次の通り編集する。

/etc/systemd/system/vpnserver.service
[Unit]
Description=SoftEther VPN Server
After=network.target

[Service]
Type=forking
User=root
ExecStart=/usr/local/vpnserver/vpnserver start
ExecStop=/usr/local/vpnserver/vpnserver stop
Restart=on-failure
RestartSec=3s

[Install]
WantedBy=multi-user.target

Ctrl + X → Y → Enterで保存。

systemctl daemon-reload
systemctl enable vpnserver
systemctl start vpnserver
reboot

サービスを有効化、起動。

6. 管理ツールからサーバーに接続、設定

クライアントPCにSoftEther Server Manager for Windowsをインストールする。
https://www.softether-download.com/ja.aspx?product=softether

  • リモートアクセスVPNサーバーを有効
  • 仮想ハブを作成
  • L2TPサーバー機能を有効
  • 事前共有キーを設定
  • VPN Azureは無効
  • ユーザーを作成
  • tapデバイス「sevpn」を作成しローカルブリッジ作成

7. IPアドレスを固定、仮想ブリッジを定義

このままではVPN接続時、サーバー自身にアクセスすることができないため次の設定をする。

nano /etc/netplan/hogehoge.yaml
  • enp2s0のIPアドレスは明示的に0.0.0.0を割り当てる
  • br0にIPアドレスを設定する
hogehoge.yaml
network:
  ethernets:
    enp2s0:
      dhcp4: false
      addresses: [0.0.0.0/24]
    tap_sevpn:
      dhcp4: false
  bridges:
    br0:
      interfaces: [enp2s0, tap_sevpn]
      addresses: [192.168.0.112/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.1, 8.8.8.8, 8.8.4.4]
  version: 2

設定を反映する

netplan apply

エラーが出る場合は、「interfaces」は記述せずに一旦上書きして上記コマンドを実行し、
再度「interfaces」を記述する。

※物理NIC:enp2s0、仮想ブリッジ:br0

8. 物理NICとtapデバイスをブリッジ

apt install -y bridge-utils
brctl addif br0 enp2s0
brctl addif br0 tap_sevpn
ip link set up dev br0

以上でVPN接続時にもサーバー自身にアクセスすることが可能になる。

9. 参考文献

  1. あまり費用と労力をかけずにVPSにVPNサーバを立てる (SoftEther VPN) - Qiita
    https://qiita.com/Wankosoba/items/3fb56443e77fd6a0b6e7

  2. softetherをubuntu18.04にインストールする - Qiita
    https://qiita.com/rimksky/items/e169f9af83ce472b4ce3

  3. ネットワークブリッジ - ArchWiki
    https://wiki.archlinux.jp/index.php/%E3%83%8D%E3%83%83%E3%83%88%E3%83%AF%E3%83%BC%E3%82%AF%E3%83%96%E3%83%AA%E3%83%83%E3%82%B8#bridge-utils_.E3.82.92.E4.BD.BF.E3.81.86

  4. SoftEherVPNでTAPデバイスとのブリッジが失敗する場合 - Qiita
    https://qiita.com/nemochu33/items/ca52cd8a5f0d0ccfb0d3

9
3
0

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
  3. You can use dark theme
What you can do with signing up
9
3