LoginSignup
3
6

More than 3 years have passed since last update.

Raspberry pi3でVPNサーバー

Last updated at Posted at 2019-07-14

iOS12用のVPNサーバ

海外や公衆Wi-fi接続用でVPNが必要になったため、インストールの備忘を書いておきます。

やること

  • SoftEther VPN(VPN Server, Linux ARM EABI 32bit)をmakeしてinstallする
  • Tapの作成
  • bridge-utilsをaptでインストールする

前提条件

有線LAN接続で行う。(eth0)

softetherインストール

以下より、ダウンロードリンクをコピーする。
http://www.softether-download.com/ja.aspx

  • ソフトウェア:SoftEtherVPN(Freeware)
  • コンポーネント:SoftEther VPN Server
  • プラットフォーム:Linux
  • CPU:ARM EABI(32bit)

ダウンロード

bash
$ cd /tmp
$ wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.30-9696-beta/softether-vpnserver-v4.30-9696-beta-2019.07.08-linux-arm_eabi-32bit.tar.gz
$ tar zxvf softether-vpnserver-v4.30-9696-beta-2019.07.08-linux-arm_eabi-32bit.tar.gz

make

bash
$ cd /tmp/vpnserver
$ make
$ sudo mv vpnserver /usr/local/
$ cd /usr/local/vpnserver
$ sudo chmod 600 *
$ sudo chmod 700 vpncmd
$ sudo chmod 700 vpnserver

自動起動設定

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

[Service]
User=root
ExecStart=/usr/local/vpnserver/vpnserver.sh
ExecStop=/usr/local/vpnserver/vpnserver stop
Type=forking
RestartSec=3s
WorkingDirectory=/usr/local/vpnserver/
ExecStartPre=/sbin/ip link set dev eth0 promisc on

[Install]
WantedBy=multi-user.target

起動時にTapデバイスが、ブリッジされないため、Sleep用のスクリプトを作成

参考サイト:
https://www.unknownengineer.net/entry/2018/09/16/153738

/usr/local/vpnserver/vpnserver.sh
#!/bin/bash

/usr/local/vpnserver/vpnserver start

sleep 5
tap=$(/sbin/ifconfig -a| awk '$1 ~ /^tap/ {print $1}')
/sbin/brctl addif br0 $tap

自動起動有効化

$ sudo systemctl enable vpnserver.service

bridge-utilsのインストール

  • ブリッジ用のユーティリティのインストール
sudo apt-get install -y bridge-utils

Tapデバイスの追加

Windowsにて、Softether管理ツールでVPN用の仮想ハブを追加

ローカルブリッジ設定で、Tapデバイスを新規作成
Tapデバイス名:softether
※tap_softetherでLinuxOS上で認識できます。

  • ブリッジインターフェースのIP固定
/etc/dhcpcd.conf
denyinterfaces eth0
interface br0
static ip_address=xxx.xxx.xxx.xxx/xx
static routers=xxx.xxx.xxx.xxx
static domain_name_servers=xxx.xxx.xxx.xxx
  • ブリッジ設定
/etc/network/interfaces
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet manual
bridge_ports eth0 tap_softether
bridge_stp off
bridge_maxwait 10

以上、備忘でした。
SoftetherでのL2TPの設定等は、いろんなサイトに書いているため省略しています。

3
6
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
3
6