概要
ずいぶん昔に自分自身にSSHする方法を記載しましたが、そもそもインストールについて記載をしていませんでした。
今回とあるIaaSにインストールしたので忘れないうちにまとめてみます。
yunabe.hatenablog.com
事前に使用するパッケージをインストール
yum install -y gcc make binutils libc-devel zlib-devel openssl-devel readline-devel ncurses-devel pthread-devel wget
使用ポート番号
以下のポートはFWを開けたり、ポートフォワードさせて下さい
L2TP UDP/1701
IPsec-nat UDP/4500
isakmp UDP/500
SSL TCP/443
Softetherダウンロード(適時最新に変えて下さい)
64bit版
wget http://jp.softether-download.com/files/softether/v4.22-9634-beta-2016.11.27-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz
32bit版
wget http://jp.softether-download.com/files/softether/v4.25-9656-rtm-2018.01.15-tree/Linux/SoftEther_VPN_Server/32bit_-_Intel_x86/softether-vpnserver-v4.25-9656-rtm-2018.01.15-linux-x86-32bit.tar.gz
※64Bitに32bit版を使用すると以下のエラーをはかれインストールに失敗します
make[1]: *** [i_read_and_agree_the_license_agreement] Segmentation fault
ダウンロードしたファイルを解凍
64bit版
tar xzf softether-vpnserver-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz
32bit版
tar xzf softether-vpnserver-v4.25-9656-rtm-2018.01.15-linux-x86-32bit.tar.gz
解凍したファイルのコンパイル
cd vpnserver/
make
作成したファイルを移動
mv /tmp/vpnserver /usr/local
cd /usr/local/vpnserver/
実行権限をつける
chmod 600 *
chmod 700 vpncmd
chmod 700 vpnserver
起動スクリプトの作成
vi /etc/init.d/vpnserver
#!/bin/sh # chkconfig: 2345 99 01 # description: SoftEther VPN Server DAEMON=/usr/local/vpnserver/vpnserver LOCK=/var/lock/subsys/vpnserver test -x $DAEMON || exit 0 case "$1" in start) $DAEMON start touch $LOCK ;; stop) $DAEMON stop rm $LOCK ;; restart) $DAEMON stop sleep 3 $DAEMON start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit 0
chmod 755 /etc/init.d/vpnserver
起動コマンド
/etc/init.d/vpnserver start
停止コマンド
/etc/init.d/vpnserver stop
自動起動登録
chkconfig --add vpnserver
自動起動(ラズベリーパイ)
vi /etc/systemd/system/softether-vpn.service
systemctl daemon-reload
systemctl enable softether-vpn.service
[Unit] Description=Softether 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
起動
systemctl start vpnserver
自動起動
systemctl enable vpnserver.service
ブリッジ作成(ラズベリーパイ)
vi /etc/network/interface
source-directory /etc/network/interfaces.d auto eth0 iface eth0 inet manual auto br0 iface br0 inet manual bridge_ports eth0 bridge_maxwait 10
vi /etc/dhcpcd.conf
denyinterfaces eth0 interfaces br0 static ip_address=192.168.1.1 static routers=192.168.1.254 static domain_name_servers=192.168.1.254
Firewall 穴あけ
firewall-cmd --add-service=https --zone=public --permanent firewall-cmd --add-port=443/tcp --zone=public --permanent firewall-cmd --add-port=500/udp --zone=public --permanent firewall-cmd --add-port=4500/udp --zone=public --permanent firewall-cmd --reload
クライアントソフトのダウンロード
クライアントソフトからサーバにアクセスする
Host名の部分にログインするサーバのIPを入れ、OKすると初期設定が始まる
※もし入れない場合はインストール方法を見直すかiptablesを見直すことをすすめます
IPsecサーバ機能の有効化と共通鍵の設定
IPsec有効化のためにチェックを入れ、さらに共通鍵をここで決める
ユーザの追加
ログインするためのユーザの追加を行う
secure NATとDHCPを有効化する
以上でインストールからIPsecサーバの一通りの設定が終わりになります