2019年01月19日
あけましておめでとうございます。
今年もよろしくお願いします。
年末はスキー行ったりでまあ楽しんでいました。
職場が今年から変わったのでまあまあ、忙しいですが作るものは変わらないですね。
スキー場とかで自宅のPCに入り、色々やる予定でしたが宿やスキー場の通信はそれほど速くなかったのです。SSHとRDPだけだとなかなか難しいですね。
OPENVPNとかで暗号なしの フリーWIFIを捕まえるとセキュリティー的にこわいのでVPNをつかうのですが、やっぱり、VPNGATEとか使うと気まぐれに落とされたりするんで帰ってきてから自前のVPNをたてることにしました。
ただ、自宅メインサーバーをVPNにすると面白くないのとセキュティ的な2重化、3重化でVPNは別に立てることにしました。
PCはあるんですが電気代とか騒音の関係でAstariskと同じでラズパイを使うことに・・・うちのは3でモデルBなんでそこそこ新しい方です。今はB+があるんで今買うならこっちですね。
んで何をやるかというと
まずはともあれ、SDカードと電源とラズパイボードを用意します。
https://www.raspberrypi.org/downloads/raspbian/
んでRaspbian Stretch Liteをダウンロードしておきます。
まあこのへんは初期のセットアップで公式などを見ればいくらでもあります。
sshを有効にしたら、とりあえず、あとはPCで作業します。
VPNのサーバーソフトはSoftEtherを使います。
wgetでダウンロードします。
wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.28-9669-beta/softether-vpnserver-v4.28-9669-beta-2018.09.11-linux-arm_eabi-32bit.tar.gz
かいとー
tar zxvf softether-vpnserver-v4.28-9669-beta-2018.09.11-linux-arm_eabi-32bit.tar.gz
移動
sudo mv vpnserver /usr/local
cd /usr/local/vpnserver/
ビルド
sudo make
権限
sudo chmod 600 *
sudo chmod 700 vpncmd
sudo chmod 700 vpnserver
sudo vim /etc/systemd/system/softether-vpn.service
[Unit]
Description=Home VPN Server Service
After=network.target
[Service]
Type=forking
User=root
ExecStart=/usr/local/vpnserver/vpnserver start
ExecStop=/usr/local/vpnserver/vpnserver stop
Restart=on-abort
WorkingDirectory=/usr/local/vpnserver/
ExecStartPre=/sbin/ip link set dev eth0 promisc on
[Install]
WantedBy=multi-user.target
権限付与
chmod +x /etc/systemd/system/softether-vpn.service
デーモンロード、起動、ステータス確認
sudo systemctl daemon-reload
sudo systemctl start softether-vpn
sudo systemctl status softether-vpn
自動起動設定
sudo systemctl enable softether-vpn
hoge@xxxxxx:~ $ cd /usr/local/vpnserver/
hoge@xxxxxx:/usr/local/vpnserver $ sudo ./vpncmd
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.28 Build 9669 (English)
Compiled 2018/09/11 12:23:27 by yagi at pc33
Copyright (c) SoftEther VPN Project. All Rights Reserved.
By using vpncmd program, the following can be achieved.
1. Management of VPN Server or VPN Bridge
2. Management of VPN Client
3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool)
Select 1, 2 or 3: 1
Specify the host name or IP address of the computer that the destination VPN Server or VPN Bridge is operating on.
By specifying according to the format 'host name:port number', you can also specify the port number.
(When the port number is unspecified, 443 is used.)
If nothing is input and the Enter key is pressed, the connection will be made to the port number 8888 of localhost (this computer).
Hostname of IP Address of Destination: ラズパイのローカルIP
If connecting to the server by Virtual Hub Admin Mode, please input the Virtual Hub name.
If connecting by server admin mode, please press Enter without inputting anything.
Specify Virtual Hub Name:
Connection has been established with VPN Server "xxx.xxx.xxx.xxx" (port 443).
You have administrator privileges for the entire VPN Server.
VPN Server/DEFAULT>usercreate
userpasswordset
psecenable
L2TP over IPsec だけYES
IPsec 事前共有鍵の文字列:てきとー
ServerPasswordSet
管理者用のパスをセットしておきましょう。デフォルトだと何もないらしいです。
ルーターのポートフォワーディング
isakmp/UDP(ポート番号 500)
ipsec-nat-t/UDP(ポート番号 4500)
ファイヤーウォールはUFWを使いました。
Ubuntuの標準ですね。
基本的にはルータとおなじだけど
esp プロトコル(プロトコル番号 50)
l2tp/UDP(ポート番号 1701)
をいれておきます。
あとはサンバやRDP、SSHも通して置くといいでしょう。
Posted at 2019/01/19 21:59:28 | |
トラックバック(0) | 日記