X260のGentooにSoftEther VPN Clientをインストールする
メモです
手順
1. softether-vpnをlayman経由でインストールする
portage/softether-vpn-4.22-r9634.ebuild at master · yTakatsukasa/portage · GitHub をインストールするため、laymanにoverlayを追加する。
$ sudo layman -a yutetsu $ sudo eix-update $ sudo emerge -qa --autounmask-write "=softether-vpn-4.22-r9634" $ dispatch-conf $ sudo emerge -qa --autounmask-write "=softether-vpn-4.22-r9634" # チェック $ sudo /opt/vpnclient/vpnclient SoftEther VPN Client service program Copyright (c) SoftEther VPN Project. All Rights Reserved. vpnclient command usage: vpnclient start - Start the SoftEther VPN Client service. vpnclient stop - Stop the SoftEther VPN Client service if the service has been already started.
2. vpnclientを起動する
$ sudo /opt/vpnclient/vpnclient start
3. vpncmdで設定する
$ sudo /opt/vpnclient/vpncmd vpncmd command - SoftEther VPN Command Line Management Utility SoftEther VPN Command Line Management Utility (vpncmd command) Version 4.22 Build 9634 (English) Compiled 2016/11/27 15:23:56 by yagi at pc30 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: 2 Specify the host name or IP address of the computer that the destination VPN Client is operating on. If nothing is input and Enter is pressed, connection will be made to localhost (this computer). Hostname of IP Address of Destination: Connected to VPN Client "localhost". # tun0という名前の仮想Nicを作成 VPN Client>NicCreate tun0 VPN Client>NicEnable tun0 # VPN Serverに接続するアカウントの追加 VPN Client>AccountCreate AccountCreate command - Create New VPN Connection Setting Name of VPN Connection Setting: vpn # アカウント設定名(なんでもよい) Destination VPN Server Host Name and Port Number: 1.2.3.4:3443 # VPN ServerのIPアドレス:ポート Destination Virtual Hub Name: VPNHUB # VPN Server側のHub名 Connecting User Name: vpn_user # VPN Serverに接続するユーザ名 Used Virtual Network Adapter Name: tun0 # さっき作った仮想Nic名 # パスワード設定 VPN Client>AccountPasswordSet vpn # アカウント設定名 パスワード入れる # VPN Serverに接続してみる VPN Client>AccountConnect vpn # アカウント設定名 # 確認 VPN Client>AccountList AccountList command - Get List of VPN Connection Settings Item |Value ----------------------------+--------------------------------------------- VPN Connection Setting Name |vpn_user Status |Connected VPN Server Hostname |1.2.3.4:443 (Direct TCP/IP Connection) Virtual Hub |VPNHUB Virtual Network Adapter Name|tun0 The command completed successfully. # vpnclient起動時に接続するように設定 VPN Client>AccountStartupSet vpn # 終了 VPN Client>exit
4. 接続してrouteを書き換える
$ sudo ifconfig #=> vpn_tun0が追加されているはず # 今のrouteを確認しておく $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.xxx.yyy.254 0.0.0.0 UG 2008 0 0 wlp4s0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 # static routeを追加しておく $ sudo route add -host 1.2.3.4 gw 10.xxx.yyy.254 $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.xxx.yyy.254 0.0.0.0 UG 2008 0 0 wlp4s0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 1.2.3.4 10.xxx.yyy.254 255.255.255.255 UGH 0 0 0 wlp4s0 # vpn_tun0にDHCPでアドレスを降らせる $ sudo dhclient vpn_tun0 # vpn_tun0のエントリが増える $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 1.2.3.1 0.0.0.0 UG 0 0 0 vpn_tun0 0.0.0.0 10.xxx.yyy.254 0.0.0.0 UG 2008 0 0 wlp4s0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 1.2.3.4 10.xxx.yyy.254 255.255.255.255 UGH 0 0 0 wlp4s0 1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 vpn_tun0 # 0.0.0.0(default)のエントリを一旦どちらも消す $ sudo route del default $ sudo route del default $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 1.2.3.4 10.xxx.yyy.254 255.255.255.255 UGH 0 0 0 wlp4s0 1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 vpn_tun0 # 0.0.0.0(default)のエントリをmetricを設定しつつ追加する $ sudo route add default gw 1.2.3.1 dev vpn_tun0 metric 2008 $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 1.2.3.1 0.0.0.0 UG 2008 0 0 vpn_tun0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 1.2.3.4 10.xxx.yyy.254 255.255.255.255 UGH 0 0 0 wlp4s0 1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 vpn_tun0
こんな感じで動いた
VPN接続をやめるとき
$ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 1.2.3.1 0.0.0.0 UG 2008 0 0 vpn_tun0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 1.2.3.4 10.xxx.yyy.254 255.255.255.255 UGH 0 0 0 wlp4s0 1.2.3.0 0.0.0.0 255.255.255.0 U 0 0 0 vpn_tun0 # vpn_tun0のエントリと、途中で追加したstatic routeを消す $ sudo route del default $ sudo route del 1.2.3.4 # vpnclientを停止させる $ sudo /opt/vpnclient/vpnclient stop # routeを確認 $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0 # 元々のエントリを追加する $ sudo route add default gw 10.xxx.yyy.254 dev wlp4s0 metric 2008 $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.xxx.yyy.254 0.0.0.0 UG 2008 0 0 wlp4s0 10.xxx.yyy.0 0.0.0.0 255.255.255.0 U 2008 0 0 wlp4s0
うまく復帰できない場合はむりやりsudo rc-service net.wlp4s0 restart
で再起動させた