LoginSignup
2

More than 5 years have passed since last update.

IDCFクラウドでVyOSの冗長化を行う。

Posted at

はじめに

2台のVyOSサーバーを使って、active-standby となる冗長構成を設定します。

事前準備

まずは冗長化するためのVyOSサーバーを2台(Master, Backup)用意します。
管理コンソールからサーバー2台とパブリックIPを取得しておきます。

情報

Master Backup メモ
パブリックIP 210.140.99.136 -
eth0 10.15.0.11 10.15.0.12 フロントエンド
VIP(eth0) 10.15.0.10 - セカンダリ
eth1 10.120.0.11 10.120.0.12 バックエンド
VIP(eth1) 10.120.0.10 - セカンダリ

イメージ図

具体的な値があった方が分かりやすいかなと思い、上記情報をできるだけイメージ図にも記載しました。
VPN移行方式検討.jpg

cloudstack-apiの利用環境設定

IDCFクラウドのツールとAPIを参考に設定してください。

設定

VIPの付与

VIPを利用するにはMaster側のNICに対してセカンダリIPとして付与する必要があります。
IDCFクラウドではセカンダリIPを付与するにはcloudstack-apiコマンドを利用して付与を行います。(管理コンソールからは付与できません。)

  • MasterのMachineIDの確認
listVirtualMachines
$ cloudstack-api listVirtualMachines -t displayname,id
+-------------+--------------------------------------+
| displayname |                  id                  |
+-------------+--------------------------------------+
| Master      | ********-****-****-****-************ |
| Backup      | ********-****-****-****-************ |
+-------------+--------------------------------------+
  • Masterで利用しているNIC IDの確認(フロント, バック両方)
listNics
$ cloudstack-api listNics --virtualmachineid <MasterのMachineID> -t ipaddress,id
+--------------+--------------------------------------+
|  ipaddress   |                  id                  |
+--------------+--------------------------------------+
| 10.15.0.101  | ********-****-****-****-************ |
| 10.120.0.101 | ********-****-****-****-************ |
+--------------+--------------------------------------+
  • SecondaryIPをMasterへ付与(フロント, バック両方)
addIpToNic
$ cloudstack-api addIpToNic --nicid <Masterで利用しているNIC ID> --ipaddress <VIP>
{
  "addiptovmnicresponse": {
    "id": "********-****-****-****-************",
    "jobid": "********-****-****-****-************" 
  }
}
  • 確認
listNics
$ cloudstack-api listNics --nicid <Masterで利用しているNIC ID> --virtualmachineid <MasterのMacineID>
{
  "listnicsresponse": {
    "count": 1,
    "nic": [
      {
        "broadcasturi": "vlan://****",
        "deviceid": "0",
        "gateway": "10.15.0.1",
        "id": "********-****-****-****-************",
        "ipaddress": "10.15.0.101",
        "isdefault": true,
        "isolationuri": "vlan://****",
        "macaddress": "**:**:**:**:**:**",
        "netmask": "255.255.248.0",
        "networkid": "********-****-****-****-************",
        "secondaryip": [
          {
            "id": "********-****-****-****-************",
            "ipaddress": "10.15.0.100" 
          }
        ],
        "traffictype": "Guest",
        "type": "Isolated",
        "virtualmachineid": "********-****-****-****-************" 
      }
    ]
  }
}

パブリックIPをSecondaryIP(VIP)へNAT設定

パブリックIPをSecondaryIP(VIP)にスタティックNATするにはcloudstack-apiを使って行う必要があります。

・パブリックIPのIDを確認

listPublicIpAddresses
$ cloudstack-api listPublicIpAddresses -t tags,ipaddress,id
+------------------------------------------------+-----------------+--------------------------------------+
|                      tags                      |    ipaddress    |                  id                  |
+------------------------------------------------+-----------------+--------------------------------------+
| []                                             | ***.***.***.*** | ********-****-****-****-************ |
| [{'key': 'cloud-description', 'value': 'NAT'}] | 210.140.99.136  | ********-****-****-****-************ |
+------------------------------------------------+-----------------+--------------------------------------+

・VIP(10.15.0.100)とのスタティックNATを設定

enableStaticNat
$ cloudstack-api enableStaticNat --ipaddressid <NAT用パブリックIPのID> --virtualmachineid <MasterのMachineID> --vmguestip <フロントエンド用VIP>
{
  "enablestaticnatresponse": {
    "success": "true" 
  }
}

VyOS冗長化設定(Master/Backup共通)

  • ホスト名変更 ※任意作業
$ configure
# set system host-name <ホスト名>
  • vrrp設定
$ configure
[edit]
# edit interfaces ethernet eth0
[edit interfaces ethernet eth0]
# set vrrp vrrp-group 100
[edit interfaces ethernet eth0]
# set vrrp vrrp-group 100 virtual-address  <フロント側VIP>
[edit interfaces ethernet eth0]
# set vrrp vrrp-group 100 priority 150  ※Backup側はpriorityを100にする。
[edit interfaces ethernet eth0]
# exit
exit
# edit interfaces ethernet eth1
[edit interfaces ethernet eth1]
# set address dhcp
[edit interfaces ethernet eth1]
# set duplex auto
[edit interfaces ethernet eth1]
# set smp_affinity auto
[edit interfaces ethernet eth1]
# set speed auto
[edit interfaces ethernet eth1]
# set vrrp vrrp-group 100
[edit interfaces ethernet eth1]
# set vrrp vrrp-group 100 virtual-address  <バック側VIP>
[edit interfaces ethernet eth1]
# set vrrp vrrp-group 100 priority 150  ※Backup側はpriorityを100にする。
[edit interfaces ethernet eth1]

# commit
[ system host-name Master ]
Stopping enhanced syslogd: rsyslogd.
Starting enhanced syslogd: rsyslogd.

[edit interfaces ethernet eth0]
# save
Saving configuration to '/config/config.boot'...
Done
[edit]
# exit
exit
  • 確認
[Master]
$ show vrrp
                                 RFC        Addr   Last        Sync
Interface         Group  State   Compliant  Owner  Transition  Group
---------         -----  -----   ---------  -----  ----------  -----
eth0              100    MASTER  no         no     4m55s       <none>
eth1              100    MASTER  no         no     11s         <none>

[Backup]
$ show vrrp
                                 RFC        Addr   Last        Sync
Interface         Group  State   Compliant  Owner  Transition  Group
---------         -----  -----   ---------  -----  ----------  -----
eth0              100    BACKUP  no         no     30s         <none>
eth1              100    BACKUP  no         no     11s         <none>
[Master]
$ show interfaces 
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             <フロント側VIP>                   u/u  
                 **.**.*.***/**
eth1             <バック側VIP>                     u/u  
                 **.**.*.***/**
lo               127.0.0.1/8                       u/u  
                 ::1/128

[Backup]
$ show interfaces 
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             **.**.*.***/**                    u/u  
eth1             **.**.*.***/**                    u/u 
lo               127.0.0.1/8                       u/u  
                 ::1/128

確認

Masterのインスタンスを停止し、VIPがBackupへ切り替わるかを確認する。

おわりに

IDCFクラウドでVyOSの冗長化を行うにあたり、
・セカンダリIPはcloudstack-apiからしか付与できない。
・セカンダリIPへのスタティックNATもcloudstack-apiからしか設定できない。
といった点がポイントです。

また今回、AWS環境とVPN接続を行う一環でこの冗長化を行いました。
AWS側のルーターは基本的に冗長構成であるため、VyOSを冗長化させておけばVPN接続を2つ用意しないで済むのが良い点だと思います。

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
2