自宅サーバをInternet公開にするためSoftEther VPNをVPS上に設定する(4)

ISP によるPrivate network内にある自宅サーバをInternet公開サーバにするため,VPSを借りてSoftEther VPNによるVPNを構築する.

自宅サーバにインストールしたSoftEther VPN Bridgeの設定を行う.

SoftEther VPN Bridgeの設定

私はCUI派なので,vpncmdコマンドで行う.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$ sudo /usr/local/vpnbridge/vpncmd localhost:5555 /SERVER 
(サーバ管理目的でvpncmdコマンド起動)
[sudo] password for user:
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.38 Build 9760 (English)
Compiled 2021/08/17 22:32:49 by buildsan at crosswin
Copyright (c) SoftEther VPN Project. All Rights Reserved.

Connection has been established with VPN Server "localhost" (port 5555).

You have administrator privileges for the entire VPN Server.

VPN Server>ServerStatusGet
(サーバの稼働状態確認)
ServerStatusGet command - Get Current Server Status
Item |Value
----------------------------------------------+-------------------------
Server Type |Standalone Server
Number of Active Sockets |23
Number of Virtual Hubs |1
Number of Sessions |1
Number of MAC Address Tables |186
Number of IP Address Tables |139
... 以降省略

VPN Server>ServerPasswordSet
(サーバ管理用パスワードの設定.必ずつける)

VPN Server>ListenerList
(VPNサーバのListenerポートの状態確認)
443,992,1194,5555の4ポートがdefaultで開いているはず.このうち5555以外を閉じる.
VPN Server>ListenerDisable
(Port 5555以外は閉じてしまおう)
VPN Server>ListenerList
ListenerList command - Get List of TCP Listeners
Port Number|Status
-----------+---------
TCP 443 |Stopped
TCP 992 |Stopped
TCP 1194 |Stopped
TCP 5555 |Listening
The command completed successfully.

VPN Server>ServerCipherGet
(VPNで利用する暗号処理のアルゴリズム一覧を取得)
VPN Server>ServerCipherSet
(VPNで利用する暗号処理のアルゴリズム一覧を設定)
とりあえず "AES256-SHA256" に設定した

次にHUBの設定を行う.vpnbridgeは初期状態で “BRIDGE” というHubが設定されている.やることは,(1)ローカルブリッジの作成, (2)カスケード接続の設定(=VPN Serverへの接続)である.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
VPN Server>HubList 
(Hubの一覧を表示)
HubList command - Get List of Virtual Hubs
Item |Value
------------------+-------------------
Virtual Hub Name |BRIDGE
Status |Online
Type |Standalone
Users |0
Groups |0
... 以下省略
(vpnbridgeは 初期設定で"BRIDGE"というHubがあるので,それを使うことにする)

VPN Server>Hub BRIDGE
(Hub "BRIDGE" に移動)

VPN Server/BRIDGE>statusget
(Hub "BRIDGE"の状態確認)
StatusGet command - Get Current Status of Virtual Hub
Item |Value
-----------------------------+-------------------
Virtual Hub Name |BRIDGE
Status |Online
Type |Standalone
SecureNAT |Disabled
... 以下省略

VPN Server/BRIDGE>bridgelist
(現在のHub に設定されているブリッジ)
VPN Server/BRIDGE>bridgecreate BRIDGE /DEVICE:vpn /TAP:yes
(仮想IFを対象としてローカルブリッジを作成する.netIFの名称は"vpn".)
実際には "tap_"がprefixとしてついた名称でnetwork interfaceが作成される
VPN Server/BRIDGE>bridgelist
(作成されたブリッジを確認)
BridgeList command - Get List of Local Bridge Connection
Number|Virtual Hub Name|Network Adapter or Tap Device Name|Status
------+----------------+----------------------------------+---------
1 |BRIDGE |vpn |Operating
The command completed successfully.

VPN Server/BRIDGE>sessionlist
(現在のHub に接続されているsessionの確認)
ローカルブリッジ作成後はローカルブリッジがセッションの1つとして表示される.
SessionList command - Get List of Connected Sessions
Item |Value
----------------+------------------
Session Name |SID-LOCALBRIDGE-1
VLAN ID |-
Location |Local Session
User Name |Local Bridge
Source Host Name|Ethernet Bridge
TCP Connections |None
Transfer Bytes |1,356
Transfer Packets|1,361
The command completed successfully.

VPN Server/DEFAULT>SecureNatDisable
VPN Server/DEFAULT>NatDisable
VPN Server/DEFAULT>DhcpDisable
(SecureNat 機能をOffにする.あわせてNat機能とDhcp機能もOffにしておく)

VPN Server/DEFAULT>SecureNatStatusGet
(SecureNat 機能の動作状況を確認)

次にBridge Hubのlocal bridgeであるNetwork interface “tap_vpn” にIP addressを
付与する.VPN server同様,VPN Bridge起動時に自動でIP addressを割り振って
欲しいので起動・停止ファイル(/etc/systemd/system/vpnbridge.service)を以下のように修正する.修正点は10,11行目の2行のみ.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=VPN Bridge
After=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/vpnbridge/vpnbridge start
ExecStop=/usr/local/vpnbridge/vpnbridge stop
Restart=always
ExecStartPost=/bin/sleep 5
ExecStartPost=/usr/bin/ip address add 192.168.xx.11/24 dev tap_vpn

[Install]
WantedBy=multi-user.target

10行目は,VPN bridgeの起動とnetwork interfaceが利用可能になるまで待機する
コマンド.11行目は “tap_vpn” へ IP address:192.168.xx.11/24 を割り当てる
コマンドである.なお割り当てるIP addressは 接続予定であるVPN Serverの
Hubに設定されたlocal bridgeと「同じnetwork」のIP addressとした.

  • VPN server (Hub:DEFAULT)
    “tap_vpn”=>192.168.xx.1/24
  • VPN bridge (Hub:BRIDGE)
    “tap_vpn”=>192.168.xx.11/24

“vpnbridge.server”ファイルを更新したので,以下のsystemdコマンドを実行し,
VPN bridgeを再起動すれば,VPN bridge起動と同時にtap_vpnにIP addressが
付与された状態になるはずである.

1
2
3
4
5
6
7
8
9
10
11
12
$ sudo systemctl daemon-reload 
(設定ファイルの再読み込み (更新後の内容の有効化))
$ sudo systemctl restart vpnbridge
(VPN bridgeの再起動)
$ ip a show tap_vpn
(Network interface "tap_vpn" の状況表示)
3: tap_vpn: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 5e:f2:ef:b7:48:5a brd ff:ff:ff:ff:ff:ff
inet 192.168.xx.11/24 scope global tap_vpn
valid_lft forever preferred_lft forever
inet6 fe80::5cf2:aaaa:bbbb:cccc/64 scope link
valid_lft forever preferred_lft forever

ここまでの作業で以下のところまで設定ができた.

  • Conoha VPSのLinuxサーバに VPN Serverをインストール・設定
  • 自宅鯖(Linuxサーバ)に VPN Bridgeをインストール・設定

次はいよいよVPN serverとVPN bridgeを接続する.
とりあえず,ここまで.

参考資料:

ends here

自宅サーバをInternet公開にするためSoftEther VPNをVPS上に設定する(4)

http://the.netaro.info/2021/10/06/2021-1006_softether-bridge-config/

Author

T.T

Posted on

2021-10-06

Updated on

2021-11-17

Licensed under