LoginSignup
23
29

More than 5 years have passed since last update.

Raspberry Pi3にVPNサーバーとVNCサーバー立ててiPhoneから艦これするまでメモ(その1)

Posted at

流れ

OSインストール

初期設定

VPNサーバー立てる ←この記事ではここまでやる

Chromiumインストール

VNCサーバー立てる

iPhoneから艦これ!

SDのフォーマット

SDフォーマッターとかでSDをフォーマットしておく。

NOOBSのダウンロード

Raspberry Pi公式サイトよりDOWNLOADS -> NOOBSと進みNOOBSをダウンロード(LITEじゃないよ)

image

ダウンロードしたら解凍して中身を全てSDカードにコピー。

OSインストール

SDカードをRaspberry PiにさしてOSインストール。(OSはもちろんRasbianを選択)

Raspberry Pi 3でRaspbian Jessieをセットアップする方法を参考に
Menu -> Preferences -> Raspberry Pi Configurationより
Systemタブ内
Password
HostName
を設定。

Localisationタブ内
Locale (Japan/UTF-8)
TimeZone (Asia/Tokyo)
Keyboard (日本語)
Wifi Country (Japan)
を設定。

初期設定

日本語環境インストール
画面左上のパソコンみたいなマークよりターミナルを起動。
sudo apt-get update
sudo apt-get -y install fonts-vlgothic ibus-mozc

vimインストール
sudo apt-get -y install vim

ここまで終わったら再起動して各種アップデートを行う。

reboot
----再起動処理-----

再起動したら再びターミナルを起動して
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

VPNサーバーの設定

参考サイト
Raspberry PiとSoftEtherでVPN接続(Raspbian Jessie)
MacユーザがRaspberry Pi2をセットアップする-1
Raspberry Pi 2 Model B で L2TP/IPSec VPNサーバを構築してみた(その1)

ブリッジユーティリティをインストール

sudo apt-get -y install bridge-utils

Raspberry Piに固定IPを設定している場合は、
sudo vim /etc/dhcpcd.conf
を編集し該当箇所をコメントアウトか削除しておく。

sudo vim /etc/network/interfaces
でbridgeの設定を以下のように追記。

/etc/network/interfaces

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#以下追記
auto br0
iface br0 inet static #固定IP
address 192.168.3.20 #Raspberry PiのIPアドレス
netmask 255.255.255.0 #サブネットマスク
broadcast 192.168.3.255 #ブロードキャストアドレス
gateway 192.168.3.1 #ゲートウェイ(うちの場合はルータ)
bridge_ports eth0 #bridgeするポート
bridge_maxwait 10

SoftEtherのインストール

SoftEtherのサイトからVPNサーバーをダウンロード。

image

ここからはルートで作業。
su -

ダウンロードしたファイルを解凍し、makeを実行。
cd ダウンロードしたファイルのあるフォルダまでのPath
tar zxvf ファイル名
cd vpnserver
make

ディレクトリを/usr/local/に移動。
cd ../
mv vpnserver /usr/local/

パーミッションを変更。
cd /usr/local/vpnserver
chmod 600 *
chmod 700 vpn*

起動スクリプト作成。
vim /etc/init.d/vpnserver

/etc/network/interfaces
#!/bin/sh
### BEGIN INIT INFO
# Provides:                 vpnserver
# Required-Start:           $local_fs $network
# Required-Stop:            $local_fs $network
# Default-Start:            2 3 4 5
# Default-Stop:             0 1 6
# Short-Description:        SoftEther VPN 4.18 RTM
# Description:              Start vpnserver daemon SoftEther VPN 4.18 Server
### END INIT INFO

DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/vpnserver

. /lib/lsb/init-functions
test -x $DAEMON || exit 0

case "$1" in
start)
sleep 3
log_daemon_msg "Starting SoftEther VPN 4.18 Server" "vpnserver"
$DAEMON start >/dev/null 2>&1
touch $LOCK
log_end_msg 0
sleep 3

# SoftEther VPNで追加した仮想tapデバイス名を調べる
tap=`/sbin/ifconfig -a| awk '$1 ~ /^tap/ {print $1}'`
/sbin/brctl addif br0 $tap
;;

stop)
log_daemon_msg "Stopping SoftEther VPN 4.18 Server" "vpnserver"
$DAEMON stop >/dev/null 2>&1
rm $LOCK
log_end_msg 0
sleep 2
;;

restart)
$DAEMON stop
sleep 2

$DAEMON start
sleep 5
# SoftEther VPNで追加した仮想tapデバイス名を調べる
tap=`/sbin/ifconfig -a| awk '$1 ~ /^tap/ {print $1}'`
/sbin/brctl addif br0 $tap
;;

status)
    if [ -e $LOCK ]
    then
        echo "vpnserver is running."
    else
        echo "vpnserver is not running."
    fi
;;
*)

echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0

実行権限を付与し、自動起動登録。
chmod +x /etc/init.d/vpnserver
apt-get -y install chkconfig
chkconfig --add vpnserver

ここまででRaspberry Pi側の設定は一旦終了。

管理マネージャー設定

Windows(or Mac)から管理マネージャーの設定をする。(参考サイト参照)

ルータ側でIP固定、ポート開放等

ルータ側でRaspberry Piの固定IPを指定。
また、VPN接続のためにUDP/500とUDP/4500を開放。

iPhoneから接続確認

設定→一般→VPN→VPN構成を追加→L2TP

説明:適当な名前
サーバ:DDNS(***.softether.net)
アカウント:サーバに登録したユーザ@ハブ名(例:test@vpn)
RSA SecurID:オフ
パスワード:ユーザに設定したパスワード
シークレット:IPsec事前共有鍵
すべての信号を送信:オン

接続できれば完了。お疲れさまでした。

23
29
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
23
29