LoginSignup
3
2

More than 5 years have passed since last update.

SoftLayer仮想サーバーでVyOSの冗長化構成を勉強4-(IPsecVPN LAN間接続編)

Last updated at Posted at 2016-08-13

1. はじめに

仮想サーバーにVyOSを導入し、IPsecとVRRPで IPsec-VPN冗長化構成 のテストを行いました。

下記情報も併せてご覧ください。

・VyOS導入
「SoftLayer仮想サーバにVyOSをインストールしました」
http://qiita.com/Mitsu-Murakita/items/d793250566a8e9f3562b
・IPsecVPN LAN間接続
「SoftLayerとVyOSでネットワークの基礎を勉強4-(IPsecVPN LAN間接続編)」
http://qiita.com/Mitsu-Murakita/items/9bb09f54494345b51ce8
・VRRP
「SoftLayer仮想サーバーでVyOSの冗長化構成を勉強1-(VRRP基本構成編)」
http://qiita.com/Mitsu-Murakita/items/15660fd4281959816a0f

2. 構成について

2-1. 全体構成

SoftLayerの東京ロケーションとシンガポールロケーションそれぞれにVyOS(IPsec用)とWindows2012R2を構築し、VRRPで冗長化構成としています。接続確認はWindowsのリモートデスクトップで行います。
01.png

02.png

【シンガポールDC側】
「vyos-SNG」のPrioityが ”250” 、「vyos-SNG02」のPrioityは ”240”
Prioity値が大きい方が"MASTER"になりますので、起動時は「vyos-SNG」が"MASTER"、「vyos-SNG02」が "BACKUP"です。
 VRRP仮想PrivateIPは”10.116.128.210”
 VRRP仮想PublicIPは”161.202.1.246”

【東京DC側】
「vyos-TOK01」のPrioityが ”250” 、「vyos-TOK02」のPrioityは ”240”
Prioity値が大きい方が"MASTER"になりますので、起動時は「vyos-TOK01」が"MASTER"、「vyos-TOK02」が "BACKUP"です。
 VRRP仮想PrivateIPは"10.132.52.200"
 VRRP仮想PublicIPは"161.202.236.154"

2-2. VyOS設定値

2-2-1. VyOS設定値(vyos-TOK)

vyos-TOK設定値
 interfaces {
     ethernet eth0 {
         address 10.132.52.225/26
         duplex auto
         hw-id 06:65:fa:44:1c:fb
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 100 {
                 advertise-interval 1
                 preempt true
                 priority 250
                 sync-group syncgroup01
                 virtual-address 10.132.52.200
             }
         }
     }
     ethernet eth1 {
         address 161.202.236.157/29
         duplex auto
         hw-id 06:b1:22:00:62:82
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 200 {
                 advertise-interval 1
                 preempt true
                 priority 250
                 sync-group syncgroup01
                 virtual-address 161.202.236.154
             }
         }
     }
     loopback lo {
     }
 }
 protocols {
     static {
         route 10.0.0.0/8 {
             next-hop 10.132.52.193 {
             }
         }
     }
 }
 service {
     ssh {
         port 22
     }
 }
 system {
     config-management {
         commit-revisions 20
     }
     console {
         device hvc0 {
             speed 9600
         }
         device ttyS0 {
             speed 9600
         }
     }
     domain-name softlayer.com
     gateway-address 161.202.236.153
     host-name vyos-TOK
     login {
         user root {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
         }
         user vyos {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
             level admin
         }
     }
     name-server 10.0.80.11
     name-server 10.0.80.12
     ntp {
         server time.service.networklayer.com {
         }
     }
     package {
         auto-sync 1
         repository community {
             components main
             distribution helium
             password ""
             url http://packages.vyos.net/vyos
             username ""
         }
     }
     syslog {
         global {
             facility all {
                 level notice
             }
             facility protocols {
                 level debug
             }
         }
     }
     time-zone Asia/Tokyo
 }
 vpn {
     ipsec {
         esp-group ESP-TOK {
             compression disable
             lifetime 1800
             mode tunnel
             pfs enable
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ike-group IKE-TOK {
             ikev2-reauth no
             key-exchange ikev1
             lifetime 3600
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ipsec-interfaces {
             interface eth1
         }
         site-to-site {
             peer 161.202.1.246 {
                 authentication {
                     mode pre-shared-secret
                     pre-shared-secret test_key_1
                 }
                 connection-type initiate
                 default-esp-group ESP-TOK
                 ike-group IKE-TOK
                 ikev2-reauth inherit
                 local-address 161.202.236.154
                 tunnel 1 {
                     allow-nat-networks disable
                     allow-public-networks disable
                     local {
                         prefix 10.132.52.192/26
                     }
                     remote {
                         prefix 10.116.128.192/26
                     }
                 }
             }
         }
     }
 }

2-2-2. VyOS設定値(vyos-TOK2)

vyos-TOK02設定値
 interfaces {
     ethernet eth0 {
         address 10.132.52.229/26
         duplex auto
         hw-id 06:a1:f6:92:52:1b
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 100 {
                 advertise-interval 1
                 preempt true
                 priority 240
                 sync-group syncgroup01
                 virtual-address 10.132.52.200
             }
         }
     }
     ethernet eth1 {
         address 161.202.236.158/29
         duplex auto
         hw-id 06:c2:b5:bb:5f:b5
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 200 {
                 advertise-interval 1
                 preempt true
                 priority 240
                 sync-group syncgroup01
                 virtual-address 161.202.236.154
             }
         }
     }
     loopback lo {
     }
 }
 protocols {
     static {
         route 10.0.0.0/8 {
             next-hop 10.132.52.193 {
             }
         }
     }
 }
 service {
     ssh {
         port 22
     }
 }
 system {
     config-management {
         commit-revisions 20
     }
     console {
         device hvc0 {
             speed 9600
         }
         device ttyS0 {
             speed 9600
         }
     }
     domain-name softlayer.com
     gateway-address 161.202.236.153
     host-name vyos-TOK2
     login {
         user root {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
         }
         user vyos {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
             level admin
         }
     }
     name-server 10.0.80.11
     name-server 10.0.80.12
     ntp {
         server time.service.networklayer.com {
         }
     }
     package {
         auto-sync 1
         repository community {
             components main
             distribution helium
             password ""
             url http://packages.vyos.net/vyos
             username ""
         }
     }
     syslog {
         global {
             facility all {
                 level notice
             }
             facility protocols {
                 level debug
             }
         }
     }
     time-zone Asia/Tokyo
 }
 vpn {
     ipsec {
         esp-group ESP-TOK {
             compression disable
             lifetime 1800
             mode tunnel
             pfs enable
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ike-group IKE-TOK {
             ikev2-reauth no
             key-exchange ikev1
             lifetime 3600
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ipsec-interfaces {
             interface eth1
         }
         site-to-site {
             peer 161.202.1.246 {
                 authentication {
                     mode pre-shared-secret
                     pre-shared-secret test_key_1
                 }
                 connection-type initiate
                 default-esp-group ESP-TOK
                 ike-group IKE-TOK
                 ikev2-reauth inherit
                 local-address 161.202.236.154
                 tunnel 1 {
                     allow-nat-networks disable
                     allow-public-networks disable
                     local {
                         prefix 10.132.52.192/26
                     }
                     remote {
                         prefix 10.116.128.192/26
                     }
                 }
             }
         }
     }
 }

2-2-3. VyOS設定値(vyos-SNG)

vyos-SNG設定値
 interfaces {
     ethernet eth0 {
         address 10.116.128.215/26
         duplex auto
         hw-id 06:77:2c:62:ea:30
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 100 {
                 advertise-interval 1
                 preempt true
                 priority 250
                 sync-group syncgroup01
                 virtual-address 10.116.128.210
             }
         }
     }
     ethernet eth1 {
         address 161.202.1.244/29
         duplex auto
         hw-id 06:0c:57:9c:f6:db
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 200 {
                 advertise-interval 1
                 preempt true
                 priority 250
                 sync-group syncgroup01
                 virtual-address 161.202.1.246
             }
         }
     }
     loopback lo {
     }
 }
 protocols {
     static {
         route 10.0.0.0/8 {
             next-hop 10.116.128.193 {
             }
         }
     }
 }
 service {
     ssh {
         port 22
     }
 }
 system {
     config-management {
         commit-revisions 20
     }
     console {
         device hvc0 {
             speed 9600
         }
         device ttyS0 {
             speed 9600
         }
     }
     domain-name softlayer.com
     gateway-address 161.202.1.241
     host-name vyos-SNG
     login {
         user root {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
             level admin
         }
         user vyos {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
             level admin
         }
     }
     name-server 10.0.80.11
     name-server 10.0.80.12
     ntp {
         server time.servive.networklayer.com {
         }
     }
     package {
         auto-sync 1
         repository community {
             components main
             distribution helium
             password ""
             url http://packages.vyos.net/vyos
             username ""
         }
     }
     syslog {
         global {
             facility all {
                 level notice
             }
             facility protocols {
                 level debug
             }
         }
     }
     time-zone Asia/Tokyo
 }
 vpn {
     ipsec {
         esp-group ESP-SNG {
             compression disable
             lifetime 1800
             mode tunnel
             pfs enable
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ike-group IKE-SNG {
             ikev2-reauth no
             key-exchange ikev1
             lifetime 3600
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ipsec-interfaces {
             interface eth1
         }
         site-to-site {
             peer 161.202.236.154 {
                 authentication {
                     mode pre-shared-secret
                     pre-shared-secret test_key_1
                 }
                 connection-type initiate
                 default-esp-group ESP-SNG
                 ike-group IKE-SNG
                 ikev2-reauth inherit
                 local-address 161.202.1.246
                 tunnel 1 {
                     allow-nat-networks disable
                     allow-public-networks disable
                     local {
                         prefix 10.116.128.192/26
                     }
                     remote {
                         prefix 10.132.52.192/26
                     }
                 }
             }
         }
     }
 }

2-2-4. VyOS設定値(vyos-SNG2)

vyos-SNG02設定値
 interfaces {
     ethernet eth0 {
         address 10.116.128.225/26
         duplex auto
         hw-id 06:92:2e:82:63:ce
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 100 {
                 advertise-interval 1
                 preempt true
                 priority 240
                 sync-group syncgroup01
                 virtual-address 10.116.128.210
             }
         }
     }
     ethernet eth1 {
         address 161.202.1.245/29
         duplex auto
         hw-id 06:1c:98:ac:2a:5b
         smp_affinity auto
         speed auto
         vrrp {
             vrrp-group 200 {
                 advertise-interval 1
                 preempt true
                 priority 240
                 sync-group syncgroup01
                 virtual-address 161.202.1.246
             }
         }
     }
     loopback lo {
     }
 }
 protocols {
     static {
         route 10.0.0.0/8 {
             next-hop 10.116.128.193 {
             }
         }
     }
 }
 service {
     ssh {
         port 22
     }
 }
 system {
     config-management {
         commit-revisions 20
     }
     console {
         device hvc0 {
             speed 9600
         }
         device ttyS0 {
             speed 9600
         }
     }
     domain-name softlayer.com
     gateway-address 161.202.1.241
     host-name vyos-SNG2
     login {
         user root {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
         }
         user vyos {
             authentication {
                 encrypted-password xxxxxxxxxxxxxxxxxxxx
                 plaintext-password ""
             }
             level admin
         }
     }
     name-server 10.0.80.11
     name-server 10.0.80.12
     ntp {
         server time.service.networklayer.com {
         }
     }
     package {
         auto-sync 1
         repository community {
             components main
             distribution helium
             password ""
             url http://packages.vyos.net/vyos
             username ""
         }
     }
     syslog {
         global {
             facility all {
                 level notice
             }
             facility protocols {
                 level debug
             }
         }
     }
     time-zone Asia/Tokyo
 }
 vpn {
     ipsec {
         esp-group ESP-TOK {
             compression disable
             lifetime 1800
             mode tunnel
             pfs enable
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ike-group IKE-TOK {
             ikev2-reauth no
             key-exchange ikev1
             lifetime 3600
             proposal 1 {
                 encryption aes256
                 hash sha1
             }
         }
         ipsec-interfaces {
             interface eth1
         }
         site-to-site {
             peer 161.202.1.246 {
                 authentication {
                     mode pre-shared-secret
                     pre-shared-secret test_key_1
                 }
                 connection-type initiate
                 default-esp-group ESP-TOK
                 ike-group IKE-TOK
                 ikev2-reauth inherit
                 local-address 161.202.236.154
                 tunnel 1 {
                     allow-nat-networks disable
                     allow-public-networks disable
                     local {
                         prefix 10.132.52.192/26
                     }
                     remote {
                         prefix 10.116.128.192/26
                     }
                 }
             }
         }
     }
 }

2-3. Windowsサーバーのスタティックルート設定

2-3-1. W2012R2-TOK(Windows)の設定

シンガポールDCネットワークへのスタティックルート設定

W2012R2-TOKでのStaticRoute設定
> route add -p 10.116.128.192 mask 255.255.255.192 10.132.52.200

2-3-2. W2012R2-SNG(Windows)の設定

東京DCネットワークへのスタティックルート設定

W2012R2-SNGKでのStaticRoute設定
> route add -p 10.132.52.192 mask 255.255.255.192 10.116.128.210

3. 接続確認

SoftLayerのVLANスパンを オフ にしてから、接続の確認を行います。
05.png

VRRPの状況を"show vrrp"、IPsecの状況を"show vpn ike sa"”show vpn ipsec sa”で確認します。

3-1. vyos-TOKの状況

06-1.png
VRRPは”master”です。
IPsecは"up"の状態で、vyos-SNGと通信確立しています。

3-2. vyos-SNGの状況

06-2.png
VRRPは”master”です。
IPsecは"up"の状態で、vyos-TOKと通信確立しています。

3-3. vyos-TOK2の状況

06-3.png
VRRPは”backup”で、IPsecは"down"です。

3-4. vyos-SNG2の状況

06-4.png
VRRPは”backup”で、IPsecは"down"です。

3-5. Windows2012Server間リモートデスクトップ接続確認

W2012R2-TOKからW2012R2-SNGへリモートデスクトップ接続します。
08.png
接続確認でき、通信状態は正常です。

4. VRRPの切り替えテスト

今まで正常に動作している、「vyos-TOK」と「vyos-SNG」をダウンさせ、接続を「vyos-TOK2」「vyos-SNG2」が引き継ぐかを確認します。
09.png

4-1. vyos-TOK2の状況

10.png
VRRPが”backup”から"master"へ変わりました。
IPsecが"down"状態でVPNサービスが停止状態なので、VPNを再起動します。
”restart vpn”
11.png
IPsecが"up"になりました。

4-2. vyos-SNG2の状況

VRRPが”backup”から"master"へ変わりました。
IPsecが"down"状態ですが、VPNサービスは起動中で相手からの接続を待っている状態です。
12.png

「vyos-TOK2」から接続要求により、正常に接続されてIPsecが"up"になりました。
13.png

4-3. Windows2012Server間リモートデスクトップ接続確認

08.png
通常、セッションの再接続操作が必要ですが、リトライ回数内で無事接続できました。

5. VPNサービスの自動起動

VRRPの機能として、VRRPサーバーの状態が「master」、「backup」、「fault」になった時のイベントを判断し、プログラムを起動することができます。
今回は、「backup」から「master」へ状態が変化したのを判断し、VPNサービスを再起動する("restart vpn")設定を行います。

設定対象サーバーは、「vyos-TOK2」と「vyos-SNG2」です。

(1)rootアカウントの有効化
VyOSユーザーでログオンしてますので、rootでログオンできるように設定します。

rootアカウントの有効化
# set system login user root authentication plaintext-password rootのパスワード 
# commit
# save

(2)rootアカウントでログオン
14.png

(3)VPNサービス再起動のスクリプト登録
/config/scripts/ディレクトリー「vrrp-state-change.sh」というファイル名でスクリプトファイルを作成します。
15.png
※ viのカーソル移動キーなどが文字化けする際は、viのコマンドset nocompatileを実行してください。
16.png

スクリプトファイルの内容は、下記の通りです。

vrrp-state-change.sh
/opt/vyatta/bin/vyatta-op-cmd-wrapper restart vpn

17.png

(4)スクリプトファイルの属性変更

vrrp-state-change.sh
# chmod 755 /config/scripts/vrrp-state-change.sh

ここまで終わりましたらexitで抜け、VyOSの編集モードで下記設定を行います。

vrrp-state-change.sh
# set interfaces ethernet eth1 vrrp vrrp-group 200 run-transition-scripts master /config/scripts/vrrp-state-change.sh
# commit
# save

6. VRRPフェイルオーバー後のVPNサービスの自動起動確認

「vyos-TOK」「vyos-SNG」を停止し、「vyos-TOK2」「vyos-SNG2」が「master」になった後、Windowsサーバーのセッション再接続の操作だけで接続が確認できたら完了です。

6-1. vyos-TOK2の状況

18.png
VRRPが”backup”から"master"へ変わり、IPsecも"up"状態です。

6-2. vyos-SNG2の状況

19.png
VRRPが”backup”から"master"へ変わり、IPsecも"up"状態です。

6-3. Windows2012Server間リモートデスクトップ接続確認

リモートデスクトップの接続リトライ内で切り替え接続が完了したため、リモートデスクトップの再接続操作なく、通信できました。
20.png

6. おわりに

VRRPの状態イベントでスクリプトを起動できるので、重要な通信部分の強化ができそうです。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2