CentOSにopenfortivpnをインストールしてVPNを張る
はじめに
AWS上のCentOSから社内の検証環境に接続したくて、openfortivpnでVPNを張ったときのメモです。
環境
# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core) # ./openfortivpn --version 1.14.1
パッケージインストール&ビルド
依存パッケージをインストールしてから、openfortivpnをビルドします。
# yum install gcc automake autoconf openssl-devel make pkg-config pppd # git clone https://github.com/adrienverge/openfortivpn.git # cd openfortivpn/ # ./autogen.sh # ./configure --prefix=/usr/local --sysconfdir=/etc # make
設定
この状態でopenfortivpn
コマンドを実行すると、下記のワーニング、エラーが出力されます。
# ./openfortivpn <接続先IPアドレス>:<ポート番号> -u <ユーザ名> -p <パスワード> WARN: You should not pass the password on the command line. Type it interactively or use a config file instead. ERROR: Gateway certificate validation failed, and the certificate digest is not in the local whitelist. If you trust it, rerun with: ERROR: --trusted-cert <ランダムな文字列> ERROR: or add this line to your config file: ERROR: trusted-cert = <ランダムな文字列> ...
内容は、
- コマンドにパスワードをべた書きするな!
- 証明書が信用できねぇ!
なので、諸々を設定ファイルに書きます。
/etc/openfortivpn/config
host = <接続先IPアドレス> port = <接続先ポート番号> username = <ユーザ名> password = <パスワード> trusted-cert = <コマンド実行時に確認した確認した文字列>
ユニットファイル作成
コマンドで都度張るのだと取り回しが悪いので、ユニットファイルを作成してsystemdで管理します。
/etc/systemd/system/openfortivpn.service
[Unit] Description=openfortivpn [Service] Restart=always ExecStart=/opt/openfortivpn/openfortivpn [Install] WantedBy=default.target
ユニットファイルをロードして起動します。お好みでenable
しても良しです。
# systemctl daemon-reload # systemctl start openfortivpn