LoginSignup
9
4

More than 3 years have passed since last update.

[Oracle Cloud] IPsec VPNをBGPでVyOSを使って接続してみた

Last updated at Posted at 2019-06-20

はじめに

Oracle Cloud Infrastructure(以下OCI)で、IPsec VPN を使用してOracleCloud外の拠点と接続する時の方式に、BGPが追加されました。
今回の記事では、VyOS(元vyatta)の仮想ルータを使用して、BGPを使った接続方法を確認します。

接続概要

以下の構成図で示している接続方式を構成していきます。左右の環境をDRGと仮想ルータの VyOS を使って、BGPで接続を行います。
構成図左側は、Oracle Cloud の Frankfurt Region となっており、メインのサイトとしています。
構成図右側は、Oracle Cloud の Ashburn Region となっていますが、オンプレミスの疑似環境として構築を行います。

001.png

手順

前提条件

VCN, Subnet, VyOS, CPE など、IPsec VPN + BGP で接続を行うための事前環境が構成されていること。

IPsec Connectionを作成

OCIのコンソール画面から、Networking メニューの、IPsec のページへ移動し、 [Create IPSec Connection] を押します

002.png

以下のパラメータを指定します

  • Customer-Premises Equipment : 事前に定義している VyOS を指定
  • DRG : 事前に作成している DRG を指定

パラメータ指定後、Show Advanced Options を選択して、新たな画面を開きます。

003.png

Tunnel 1 のタブで、以下パラメータを指定します

  • Name : 任意の名前を指定
  • Routing Type : BGP DYNAMIC ROUTINGを指定
  • BGP ASN : 65000 を指定 (プライベートASNであればなんでも良い)
  • INSIDE TUNNEL INTERFACE - CPE : VyOS側のIPsec トンネル用のインターフェースのIPアドレスを指定。OCIやオンプレミスとは重複していないIPアドレスを指定する必要があるため、/31 を使用するとよい
  • INSIDE TUNNEL INTERFACE - ORACLE : Oracle側のIPsec トンネル用のインターフェースのIPアドレスを指定。OCIやオンプレミスとは重複していないIPアドレスを指定する必要があるため、/31 を使用するとよい

004.png

同様に、Tunnel2タブで、以下パラメータを指定します

  • Name : 任意の名前を指定
  • Routing Type : BGP DYNAMIC ROUTINGを指定
  • BGP ASN : 65000 を指定 (プライベートASNであればなんでも良い)
  • INSIDE TUNNEL INTERFACE - CPE : VyOS側のIPsec トンネル用のインターフェースのIPアドレスを指定。OCIやオンプレミスとは重複していないIPアドレスを指定する必要があるため、/31 を使用するとよい
  • INSIDE TUNNEL INTERFACE - ORACLE : Oracle側のIPsec トンネル用のインターフェースのIPアドレスを指定。OCIやオンプレミスとは重複していないIPアドレスを指定する必要があるため、/31 を使用するとよい

上記のパラメータを指定後、[Create IPsec Connection] を選択して作成します。

005.png

VyOSの設定

VyOSの設定を行います。なお、VyOSのバージョンは、1.2.0を使用しています

vyos@vyos:~$ show version
Version:          VyOS 1.2.0-rolling+201904260337
Built by:         autobuild@vyos.net
Built on:         Fri 26 Apr 2019 03:37 UTC
Build ID:         f5be1973-3184-427e-9024-e6972c144512

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  QEMU
Hardware model:   Standard PC (i440FX + PIIX, 1996)
Hardware S/N:     Unknown
Hardware UUID:    Unknown

Copyright:        VyOS maintainers and contributors

IPsecの設定

VyOSにログインし、Configモードへ移行します

configure

VPN用のVTI(Virtual Tunnel Interface) を2個作成します。ここで指定するIPアドレスは、OCIの IPsec Connection を作成するときに指定した INSIDE TUNNEL INTERFACE - CPE の IPアドレスを指定します。

set interface vti vti0 description "OCI IPSec tunnel 1"
set interface vti vti0 address 192.168.0.102/31
set interface vti vti1 description "OCI IPSec tunnel 2"
set interface vti vti1 address 192.168.0.104/31
set vpn ipsec ipsec-interfaces interface eth0

IKE(Internet Key Exchange) の設定を行います。IKEは鍵交換を行うためのプロトコルです。IKEは、ISAKMP/Oakleyというプロトコルをもとにして作られています。

set vpn ipsec ike-group oracle proposal 1
set vpn ipsec ike-group oracle proposal 1 encryption aes256
set vpn ipsec ike-group oracle proposal 1 hash sha256
set vpn ipsec ike-group oracle lifetime 28800
set vpn ipsec ike-group oracle proposal 1 dh-group 5

ESP(Encapsulated Security Payload) の設定を行います。ESPは、パケットの改ざんが行われていないか認証を行うプロトコルです。

set vpn ipsec esp-group oracle proposal 1
set vpn ipsec esp-group oracle proposal 1 encryption aes256
set vpn ipsec esp-group oracle proposal 1 hash sha1
set vpn ipsec esp-group oracle lifetime 3600
set vpn ipsec esp-group oracle pfs enable

OCIのDRGとVyOS間で、IPsec のピアを設定します。
peerに入力する Global IP は、OCIのIPsec Connection配下にある、2個の Global IP をそれぞれ入力します。
pre-shared-secretの値は、IPsec Connection配下にあるTunnelで表示される「Shared Secret」の値を入力します。

# peer 1
set vpn ipsec site-to-site peer 130.61.7.56
set vpn ipsec site-to-site peer 130.61.7.56 authentication mode pre-shared-secret
set vpn ipsec site-to-site peer 130.61.7.56 authentication pre-shared-secret secret1
set vpn ipsec site-to-site peer 130.61.7.56 authentication id 129.213.37.197
set vpn ipsec site-to-site peer 130.61.7.56 default-esp-group oracle
set vpn ipsec site-to-site peer 130.61.7.56 ike-group oracle
set vpn ipsec site-to-site peer 130.61.7.56 local-address 10.100.0.3
set vpn ipsec site-to-site peer 130.61.7.56 vti bind vti0

# peer 2
set vpn ipsec site-to-site peer 130.61.6.56
set vpn ipsec site-to-site peer 130.61.6.56 authentication mode pre-shared-secret
set vpn ipsec site-to-site peer 130.61.6.56 authentication pre-shared-secret secret2
set vpn ipsec site-to-site peer 130.61.6.56 authentication id 129.213.37.197
set vpn ipsec site-to-site peer 130.61.6.56 default-esp-group oracle
set vpn ipsec site-to-site peer 130.61.6.56 ike-group oracle
set vpn ipsec site-to-site peer 130.61.6.56 local-address 10.100.0.3
set vpn ipsec site-to-site peer 130.61.6.56 vti bind vti1

BGPの設定

OCI と VyOS 間で、BGPの設定を行います。なお、OCI側のASNは31898となっています。

set protocols bgp 65000
set protocols bgp 65000 neighbor 192.168.0.103 remote-as 31898
set protocols bgp 65000 neighbor 192.168.0.103 ebgp-multihop 100
set protocols bgp 65000 neighbor 192.168.0.103 update-source '10.100.0.3'
set protocols bgp 65000 neighbor 192.168.0.105 remote-as 31898
set protocols bgp 65000 neighbor 192.168.0.105 ebgp-multihop 100
set protocols bgp 65000 neighbor 192.168.0.105 update-source '10.100.0.3'
set protocols bgp 65000 parameters router-id '10.100.0.3'

Oracle Cloud へBGP経路をアドバタイズするNetworkを定義します。

set protocols bgp 65000 address-family ipv4-unicast network 10.100.0.0/16

BGPの確認

BGPで経路交換したのちの情報を確認します。OCIで作成した Subnet の経路が BGP によって広告されています。

vyos@vyos:~$ show ip bgp
BGP table version is 43, local router ID is 10.100.0.3, vrf id 0
Default local pref 100, local AS 65000
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*= 10.0.0.0/24      192.168.0.103                          0 31898 i
*>                  192.168.0.105                          0 31898 i
*= 10.0.1.0/24      192.168.0.103                          0 31898 i
*>                  192.168.0.105                          0 31898 i
*= 10.0.2.0/24      192.168.0.103                          0 31898 i
*>                  192.168.0.105                          0 31898 i
*> 10.100.0.0/16    0.0.0.0                  0         32768 i

Displayed  4 routes and 7 total paths

サマリーを確認します。

vyos@vyos:~$ show ip bgp summary

IPv4 Unicast Summary:
BGP router identifier 192.168.0.104, local AS number 65000 vrf-id 0
BGP table version 6
RIB entries 5, using 800 bytes of memory
Peers 2, using 41 KiB of memory

Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
192.168.0.103   4      31898       5       5        0    0    0 00:01:14            3
192.168.0.105   4      31898       5       5        0    0    0 00:01:14            3

Total number of neighbors 2

BGP ネイバーの詳細情報を確認します。BGP state が Established となっていればOKです。

vyos@vyos:~$ show ip bgp neighbors
BGP neighbor is 192.168.0.103, remote AS 31898, local AS 65000, external link
  BGP version 4, remote router ID 192.168.0.103, local router ID 10.100.0.3
  BGP state = Established, up for 03:49:18
  Last read 00:00:24, Last write 00:00:17
  Hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    4 Byte AS: advertised and received
    AddPath:
      IPv4 Unicast: RX advertised IPv4 Unicast
    Route refresh: advertised and received(old & new)
    Address Family IPv4 Unicast: advertised and received
    Hostname Capability: advertised (name: vyos,domain name: n/a) not received
    Graceful Restart Capabilty: advertised and received
      Remote Restart timer is 120 seconds
      Address families by peer:
        none
  Graceful restart information:
    End-of-RIB send: IPv4 Unicast
    End-of-RIB received: IPv4 Unicast
  Message statistics:
    Inq depth is 0
    Outq depth is 0
                         Sent       Rcvd
    Opens:                  4          4
    Notifications:          6          0
    Updates:               13          9
    Keepalives:          2898       3108
    Route Refresh:          0          0
    Capability:             0          0
    Total:               2921       3121
  Minimum time between advertisement runs is 0 seconds
  Update source is 10.100.0.3

 For address family: IPv4 Unicast
  Update group 4, subgroup 4
  Packet Queue length 0
  Community attribute sent to this neighbor(all)
  3 accepted prefixes

  Connections established 4; dropped 3
  Last reset 03:49:50, due to NOTIFICATION sent (Cease/Other Configuration Change)
  External BGP neighbor may be up to 100 hops away.
Local host: 192.168.0.102, Local port: 179
Foreign host: 192.168.0.103, Foreign port: 63793
Nexthop: 192.168.0.102
Nexthop global: fe80::5efe:a64:3
Nexthop local: fe80::5efe:a64:3
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 97 ms
Read thread: on  Write thread: on

BGP neighbor is 192.168.0.105, remote AS 31898, local AS 65000, external link
  BGP version 4, remote router ID 192.168.0.105, local router ID 10.100.0.3
  BGP state = Established, up for 03:49:17
  Last read 00:00:28, Last write 00:00:17
  Hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    4 Byte AS: advertised and received
    AddPath:
      IPv4 Unicast: RX advertised IPv4 Unicast
    Route refresh: advertised and received(old & new)
    Address Family IPv4 Unicast: advertised and received
    Hostname Capability: advertised (name: vyos,domain name: n/a) not received
    Graceful Restart Capabilty: advertised and received
      Remote Restart timer is 120 seconds
      Address families by peer:
        none
  Graceful restart information:
    End-of-RIB send: IPv4 Unicast
    End-of-RIB received: IPv4 Unicast
  Message statistics:
    Inq depth is 0
    Outq depth is 0
                         Sent       Rcvd
    Opens:                  4          4
    Notifications:          6          0
    Updates:               15          9
    Keepalives:          2898       3170
    Route Refresh:          0          0
    Capability:             0          0
    Total:               2923       3183
  Minimum time between advertisement runs is 0 seconds
  Update source is 10.100.0.3

 For address family: IPv4 Unicast
  Update group 4, subgroup 4
  Packet Queue length 0
  Community attribute sent to this neighbor(all)
  3 accepted prefixes

  Connections established 4; dropped 3
  Last reset 03:49:50, due to NOTIFICATION sent (Cease/Other Configuration Change)
  External BGP neighbor may be up to 100 hops away.
Local host: 192.168.0.104, Local port: 179
Foreign host: 192.168.0.105, Foreign port: 59547
Nexthop: 192.168.0.104
Nexthop global: fe80::5efe:a64:3
Nexthop local: fe80::5efe:a64:3
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 96 ms
Read thread: on  Write thread: on

vyos@vyos:~$

通信確認

疑似オンプレミス側に存在するインスタンスから、OCIのマシンへPingが通ることを確認します。

ubuntu@onpremins01:~$ ping 10.0.0.2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=62 time=94.8 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=62 time=94.6 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=62 time=94.7 ms
^C
--- 10.0.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 94.647/94.732/94.819/0.070 ms

SSHで接続可能なことを確認します

ubuntu@onpremins01:~$ ssh 10.0.0.2
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-1010-oracle x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Jun 20 13:15:09 UTC 2019

  System load:  0.0               Processes:           119
  Usage of /:   2.9% of 44.97GB   Users logged in:     0
  Memory usage: 1%                IP address for ens3: 10.0.0.2
  Swap usage:   0%


 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 packages can be updated.
0 updates are security updates.

Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings


Last login: Thu Jun 20 09:59:00 2019 from 10.100.0.2

参考URL

OCI BGP
https://qiita.com/shirok/items/199d624ff414b0441576

VyOS BGP
https://support.vyos.io/en/guides/vyos-user-guide/user-guide/routing/bgp

9
4
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
9
4