この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
こんにちは、菊池です。
先の記事にて、GCPとのVPN接続について紹介しました。
この記事では、GCP側のVPNゲートウェイは冗長化された高可用性(HA)VPN構成をとっていますので、99.99%のSLAとなります。しかし、シングル構成での接続や、静的ルーティングで接続したい場合には、高可用性(HA)VPNではなくClassic VPNを選択することになります。今回は、Classic VPNを使って動的ルーティング(BGP)と静的ルーティングでの接続をやってみました。
Classic VPNで接続する
構成イメージは以下の通りです。以前の記事と同様に、オンプレ側ルータはCisco C841Mを使い、インターネット接続ルータの内側にあるNATトラバーサルでVPN接続します。
VPN接続
まずは動的ルート(BGP)から、VPN接続を作成していきます。Classic VPNを選択して先に進みます。
VPNゲートウェイの作成です。名前とリージョン、VPCを選択し、IPアドレスを作成します。
VPN接続に利用するパブリックIPを割り当てます。名前は任意のものを設定可能です。
パブリックIPが発行されました。
続いて、接続情報を設定します。オンプレ側のパブリックIPを入力し、IKE事前共有キーを生成します。ルーティングはまずは動的(BGP)を選択。クラウドルータがない場合は作成しましょう。
BGPセッション情報を入力します。ピア側のASNとトンネルに割り当てるIPアドレス(リンクローカルアドレスの/30を割り当て)を決めます。
設定が入力できたら、作成します。
ピアルータ(オンプレ側のVPN接続ルータ)のIPSec VPN設定です。以前のHA VPNと同様ですが、シングル接続なので設定は1つで問題ありません。
crypto ikev2 proposal tunnel1
encryption aes-cbc-256 aes-cbc-192 aes-cbc-128
integrity sha256
group 16
exit
crypto ikev2 policy tunnel1
proposal tunnel1
crypto ikev2 keyring tunnel1
peer xxx.xxx.xxx.85
address xxx.xxx.xxx.85
pre-shared-key xxxxxxxxxxxxxxxxxxxxxxxxxxxx
exit
crypto ikev2 profile tunnel1
match identity remote address xxx.xxx.xxx.85 255.255.255.255
identity local address 222.xxx.xxx.xxx
authentication local pre-share
authentication remote pre-share
keyring local tunnel1
lifetime 36000
dpd 60 5 periodic
exit
crypto ipsec transform-set tunnel1 esp-aes 256 esp-sha256-hmac
mode tunnel
exit
crypto ipsec profile ipsec-profile-tunnel1
set security-association lifetime kilobytes 102400000
set transform-set tunnel1
set pfs group16
set ikev2-profile tunnel1
exit
interface Tunnel1
ip address 169.254.0.2 255.255.255.252
ip tcp adjust-mss 1350
tunnel source 192.168.1.253
tunnel mode ipsec ipv4
tunnel destination xxx.xxx.xxx.85
tunnel protection ipsec profile ipsec-profile-tunnel1
exit
これで問題なければ、VPN接続が確立します。
動的ルーティング(BGP)の場合
続いて、動的ルーティング(BGP)固有の設定です。以下のように、BGPを設定しました。
router bgp 65000
bgp log-neighbor-changes
neighbor 169.254.0.1 remote-as 65100
neighbor 169.254.0.1 timers 20 60 60
address-family ipv4
network 10.10.10.0 mask 255.255.255.0
neighbor 169.254.0.1 activate
exit-address-family
設定に問題なければ、VPN、BGP共にセッションが確立します。
BGPテーブルで、受け取っている経路情報を確認します。
#show ip bgp
BGP table version is 6, local router ID is 192.168.1.253
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.10.10.0/24 0.0.0.0 0 32768 i
*> 172.16.0.0 169.254.0.1 100 0 65100 ?
*> 172.17.0.0 169.254.0.1 312 0 65100 ?
*> 172.18.0.0 169.254.0.1 495 0 65100 ?
*> 172.19.0.0 169.254.0.1 100 0 65100 ?
シングル接続のため、受け取ったルートは全てルートテーブルにも反映されました。
#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.1.1
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.10.10.0/24 is directly connected, Vlan1
L 10.10.10.254/32 is directly connected, Vlan1
S 10.212.134.0/24 [1/0] via 10.10.10.253
169.254.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 169.254.0.0/30 is directly connected, Tunnel1
L 169.254.0.2/32 is directly connected, Tunnel1
B 172.16.0.0/16 [20/100] via 169.254.0.1, 00:00:21
B 172.17.0.0/16 [20/312] via 169.254.0.1, 00:00:21
B 172.18.0.0/16 [20/495] via 169.254.0.1, 00:00:21
B 172.19.0.0/16 [20/100] via 169.254.0.1, 00:00:21
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/5
L 192.168.1.253/32 is directly connected, GigabitEthernet0/5
VPCのルートテーブルにも、オンプレ側の経路情報が反映されました。
動的ルートの方は、接続がシングルになっただけでHA VPNと特に変わる部分はありませんでした。
ルートベースのルーティングの場合
次に、ルートベースのルーティング(静的ルート)を試してみます。先ほど作成した動的ルート(BGP)のVPNを一旦削除し、再度VPN接続を作成していきます。
VPNゲートウェイは先ほど作成したものがそのまま利用可能です。
名前、リモートピアアドレス、IKE事前共有キーは同じものを設定します。ルーティングに、[ルートベース] を選択し、オンプレ側ネットワークのIP範囲 [10.10.10.0/24] を入力しました。
VPNの設定は同様なので、そのまま先ほどのVPN接続設定のままでトンネルが接続可能です。
VPCのルートテーブルには、ルーティングオプションで設定した宛先ネットワークが反映されます。BGPの場合と異なり、この場合には[優先度] の値が1000となっています。
オンプレ側のルータの設定です。GCPのVPCのネットワークをスタティックルートで追加します。
ip route 172.16.0.0 255.255.0.0 Tunnel1
ルートテーブルに追加されました。
#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.1.1
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.10.10.0/24 is directly connected, Vlan1
L 10.10.10.254/32 is directly connected, Vlan1
S 10.212.134.0/24 [1/0] via 10.10.10.253
169.254.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 169.254.0.0/30 is directly connected, Tunnel1
L 169.254.0.2/32 is directly connected, Tunnel1
S 172.16.0.0/16 is directly connected, Tunnel1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/5
L 192.168.1.253/32 is directly connected, GigabitEthernet0/5
動的ルート(BGP)、静的ルートどちらの場合にも、オンプレからVPCのサーバに対して疎通も確認できました。
$ ping 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.
64 bytes from 172.16.0.2: icmp_seq=1 ttl=62 time=41.9 ms
64 bytes from 172.16.0.2: icmp_seq=2 ttl=62 time=42.4 ms
64 bytes from 172.16.0.2: icmp_seq=3 ttl=62 time=41.8 ms
64 bytes from 172.16.0.2: icmp_seq=4 ttl=62 time=46.6 ms
64 bytes from 172.16.0.2: icmp_seq=5 ttl=62 time=41.7 ms
64 bytes from 172.16.0.2: icmp_seq=6 ttl=62 time=41.5 ms
まとめ
GCPへのClassic VPN接続を試しました。本番運用では高可用性(HA)VPNを使うことが多いと思いますが、シングル接続や静的ルーティングなどの要件によっては、まだClassic VPNを使う機会もあるかと思います。要件に応じて適切に使い分けましょう。