LoginSignup
3
4

More than 3 years have passed since last update.

NTT光回線経由でIPoEを用いてAWS環境とSite-to-Site VPN接続(VGW経由)を行う(BGPルーティング)

Posted at

はじめに

前回の投稿で、自宅用にCisco891ルータを調達し、NTT光とのIPoE (DS-LiteによるIPv4 over IPv6接続)まで構築することができました。今回、AWSとの間で、VGW (Virtual Private Gateway)による基本的なVPN接続を行い、どのような接続方式になるのかを検証してみます。

システム構成イメージ

AWS側との接続は以下のネットワーク構成イメージになります。
image.png

  • VGWをVPCに接続
  • CGW(家庭用ルータ)はIPoEによるPPPoEアドレスを設定
  • VPNはSite-to-Site VPNによる構成を行う
  • 動的ルーティングを採用する(BGP)

AWS側設定

  • CGW追加
    • グローバルIPアドレスはユニークなtagetが必要
    • 今回はCGW側でPPPoE取得するIPv4 Global IPアドレスを設定する
    • ASN(AS番号)はプライベートASである65000が振られる image.png
  • VGW設定
    • BGPのASN(AS番号)はAmazonのデフォルトASNを用いる
    • 対象のVPCにアタッチする image.png
  • Site-to-Site VPN設定
    • CGW/VGW設定を用いてSite-to-Site VPN設定を行う
    • ルーティングオプションは動的(BGP)を選定する
    • 作成後「設定のダウンロード」より、各ベンダーのサンプルコンフィグファイルをダウンロード出来る image.png
  • ルートテーブル設定
    • VPN(VGW)経由で伝播されるBGPのルーティング情報をVPC側に反映させるため、ルートテーブルの「ルート伝達の編集」で仮想プライベートゲートウェイの伝播をYesにする
    • デフォルトは"No"のため、有効化しないとVPC側からの戻りが無くなるので注意 image.png

Cisco Router側構成

AWSが作成するサンプルコンフィグから、以下が注意事項になります。

  • サンプル設定はデフォルトルート(0.0.0.0/0)がVPN先に向けられるので注意
    • "neighbor default-originate"を用いて、CGW側からの0.0.0.0を通知する設定が入る
    • "network 0.0.0.0"でCGWのスピーカとしてdefault routeを伝搬する
  • AWSからのInternet接続はIGW経由(直Internet)を想定する場合は以下を設定
    • "neighbor default-originate"を消す
    • "network x.x.x.x"はオンプレ側の自社ネットワーク範囲を設定する

neighbor default-originate

BGP スピーカー(ローカル ルータ)でデフォルト ルート 0.0.0.0 をネイバーに送信してデフォルト ルートとして使用できるようにするには、アドレス ファミリまたはルータ コンフィギュレーション モードで neighbor default-originate コマンドを使用します。 デフォルトとして使用するルートを送信しないようにするには、このコマンドの no 形式を使用します。

上記を注意して設定したRouter Configurationが以下になります。

c891home-hisnakad#show run
Building configuration...

Current configuration : 5963 bytes
!
version 15.3
no service pad
service tcp-keepalives-in
service tcp-keepalives-out
service timestamps debug datetime localtime year
service timestamps log datetime localtime year
service password-encryption
service sequence-numbers
!
hostname c891home
!
!
logging buffered 512000
!         
no aaa new-model
memory-size iomem 15
clock timezone JST 9 0
clock calendar-valid
!
!
!
!
!
!
!
ip dhcp pool MyHome
 network 192.168.2.0 255.255.255.0
 default-router 192.168.2.1 
 dns-server 8.8.8.8 
 lease 7
!
!
!
no ip bootp server
ip domain list flets-east.jp
ip domain list iptvf.jp
ip cef
ipv6 unicast-routing
ipv6 cef
ipv6 dhcp pool STATELESS
 import dns-server
 import domain-name
!
!
crypto keyring keyring-vpn-054f364e1ba5cc369-1  
  local-address 119.243.XXX.XXX
  pre-shared-key address 52.194.XXX.XXX key dULFDTopD2Movqn3aZBO5ZrDWxT8MvIA
crypto keyring keyring-vpn-054f364e1ba5cc369-0  
  local-address 119.243.XXX.XXX
  pre-shared-key address 18.177.XXX.XXX key bgCgmNtPuJgx6KdLYw1KHqZMpnBsPXyb
!
crypto isakmp policy 200
 encr aes
 authentication pre-share
 group 2
 lifetime 28800
!
crypto isakmp policy 201
 encr aes
 authentication pre-share
 group 2
 lifetime 28800
crypto isakmp keepalive 10 10
crypto isakmp profile isakmp-vpn-054f364e1ba5cc369-0
   keyring keyring-vpn-054f364e1ba5cc369-0
   match identity address 18.177.XXX.XXX 255.255.255.255 
   local-address 119.243.XXX.XXX
crypto isakmp profile isakmp-vpn-054f364e1ba5cc369-1
   keyring keyring-vpn-054f364e1ba5cc369-1
   match identity address 52.194.XXX.XXX 255.255.255.255 
   local-address 119.243.XXX.XXX
!
crypto ipsec security-association replay window-size 128
!
crypto ipsec transform-set ipsec-prop-vpn-054f364e1ba5cc369-0 esp-aes esp-sha-hmac 
 mode tunnel
crypto ipsec transform-set ipsec-prop-vpn-054f364e1ba5cc369-1 esp-aes esp-sha-hmac 
 mode tunnel
crypto ipsec df-bit clear
!
!
crypto ipsec profile ipsec-vpn-054f364e1ba5cc369-0
 set transform-set ipsec-prop-vpn-054f364e1ba5cc369-0 
 set pfs group2
!
crypto ipsec profile ipsec-vpn-054f364e1ba5cc369-1
 set transform-set ipsec-prop-vpn-054f364e1ba5cc369-1 
 set pfs group2
!
!
!
!
!
!
!
interface Tunnel1
 ip address 169.254.234.102 255.255.255.252
 ip virtual-reassembly in
 ip tcp adjust-mss 1379
 tunnel source 119.243.XXX.XXX
 tunnel mode ipsec ipv4
 tunnel destination 18.177.XXX.XXX
 tunnel protection ipsec profile ipsec-vpn-054f364e1ba5cc369-0
!
interface Tunnel2
 ip address 169.254.200.170 255.255.255.252
 ip virtual-reassembly in
 ip tcp adjust-mss 1379
 tunnel source 119.243.XXX.XXX
 tunnel mode ipsec ipv4
 tunnel destination 52.194.XXX.XXX
 tunnel protection ipsec profile ipsec-vpn-054f364e1ba5cc369-1
!
interface BRI0
 no ip address
 encapsulation hdlc
 shutdown
 isdn termination multidrop
!
interface FastEthernet0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface GigabitEthernet0
 no ip address
 no cdp enable
!
interface GigabitEthernet1
 no ip address
 no cdp enable
!
interface GigabitEthernet2
 no ip address
 no cdp enable
!
interface GigabitEthernet3
 no ip address
 no cdp enable
!
interface GigabitEthernet4
 no ip address
 no cdp enable
!
interface GigabitEthernet5
 no ip address
 no cdp enable
!
interface GigabitEthernet6
 no ip address
 no cdp enable
!
interface GigabitEthernet7
 no ip address
 no cdp enable
!         
interface GigabitEthernet8
 description *** NTT Hikari PoE ***
 no ip address
 duplex auto
 speed auto
 ipv6 address autoconfig default
 ipv6 enable
 ipv6 dhcp client pd PREFIX
 pppoe enable group global
 pppoe-client dial-pool-number 1
!
interface Vlan1
 description *** Home Network 192_168_1_0 ***
 ip address 192.168.2.1 255.255.255.0
 ip nat inside
 ip virtual-reassembly in
 ipv6 address PREFIX ::1:0:0:0:1/64
 ipv6 enable
 ipv6 nd other-config-flag
 ipv6 dhcp server STATELESS
!
interface Dialer1
 bandwidth 1048576
 ip address negotiated
 ip mtu 1454
 ip nat outside
 ip virtual-reassembly in
 encapsulation ppp
 ip tcp adjust-mss 1414
 dialer pool 1
 dialer-group 1
 ppp mtu adaptive
 ppp authentication chap callin
 ppp chap hostname [ISP PPP Username]
 ppp chap password [ISP PPP password]
 no cdp enable
!
router bgp 65000
 bgp log-neighbor-changes
 neighbor 169.254.200.169 remote-as 64512
 neighbor 169.254.200.169 timers 10 30 30
 neighbor 169.254.234.101 remote-as 64512
 neighbor 169.254.234.101 timers 10 30 30
 !
 address-family ipv4
  network 192.168.2.0
  neighbor 169.254.200.169 activate
  neighbor 169.254.200.169 soft-reconfiguration inbound
  neighbor 169.254.234.101 activate
  neighbor 169.254.234.101 soft-reconfiguration inbound
 exit-address-family
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip dns server
ip nat inside source list 1 interface Dialer1 overload
ip route 0.0.0.0 0.0.0.0 Dialer1
!
ip access-list extended remoteaccess
 permit ip 192.168.2.0 0.0.0.255 any log-input
!
dialer-list 1 protocol ip permit
no cdp run
!
access-list 1 permit 192.168.2.0 0.0.0.255
!
control-plane
!
!
!
!
!
!
!
!
line con 0
 no modem enable
line aux 0
line 3
 modem InOut
 speed 115200
 flowcontrol hardware
line vty 0 4
 access-class remoteaccess in
 password [password]
 login
 transport input all
!
!
end

接続結果

CGW側(Cisco)のBGP情報を見ると、AWS側とのneighbor情報が見えます。
AWS側ルータの設定はVGWからは設定ができないのですが、VPNトンネルの二つに対してMED(Metric)=100,200が設定されているのが分かります。
MEDは値が小さい方が優先されるため、169.254.200.169のインターフェースであるTunnel2が優先されます。

ciscor#show ip bgp  
BGP table version is 10, local router ID is 192.168.2.1
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.0.0.0/16      169.254.200.169        100             0 64512 i
 *                    169.254.234.101        200             0 64512 i
 *>  192.168.2.0      0.0.0.0                  0         32768 i
c891#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

Gateway of last resort is 0.0.0.0 to network 0.0.0.0

S*    0.0.0.0/0 is directly connected, Dialer1
      10.0.0.0/16 is subnetted, 1 subnets
B        10.0.0.0 [20/100] via 169.254.200.169, 23:48:27
      119.0.0.0/32 is subnetted, 1 subnets
C        119.243.48.204 is directly connected, Dialer1
      133.205.0.0/32 is subnetted, 1 subnets
C        133.205.18.234 is directly connected, Dialer1
      169.254.0.0/16 is variably subnetted, 4 subnets, 2 masks
C        169.254.200.168/30 is directly connected, Tunnel2
L        169.254.200.170/32 is directly connected, Tunnel2
C        169.254.234.100/30 is directly connected, Tunnel1
L        169.254.234.102/32 is directly connected, Tunnel1
      192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.2.0/24 is directly connected, Vlan1
L        192.168.2.1/32 is directly connected, Vlan1

AWS側のVPCルート情報も見てみましょう。
VGWからの伝播設定が有効化されている場合は、以下のようにVPN経由のオンプレミス経路情報(192.168.2.0)がBGP経由で伝播されていることが分かります。
image.png

BGP経路の設定を反映させる場合、ルート情報の更新以外の設定(MEDやLocal Preferenceなど)はネットワーク変更に見なされないため、手動でBGPのリセットが必要です。bgp resetを行いましょう。BGPのルーティングテーブルが更新されます。

c891home#clear ip bgp 169.254.XXX.XXX soft

ISP接続に関わった方はよく使ったコマンドになりますね...

まとめ

本記事は標準的なAWS環境とのCiscoルータを用いたVPN接続を試してみました。NTT光回線のIPoEを使うことで、自宅からでも動的ルーティングであるBGPの動作が分かるので、どなたかの参考になれば幸いです。

VGWはECMP(等コストパスルーティング)をサポートしていないため、双方のVPNパスを等コストで負荷分散する場合は、Transit Gateway経由のVPN構成が必要になります。これはまた次回試してみたいと思います。

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