Metonymical Deflection

ゆるく日々のコト・たまにITインフラ

MPLS over GRE over IPSec with IKEv2

Cisco891FJ×2台構成でMPLS over GRE over IPSec with IKEv2を実装してみました。

IPSec with IKEv2の部分について
トンネルの暗号化はcrypto mapを使うとACLを書くのが大変なので、AWSのVGWでもサンプルConfigが公開されているipsec profileにしています。
また、isakmpはちょっぴり不安なのでIKEv2に変更しています。

MPLS over GREの部分について
MP-BGPにてMPLSを使うため、tunnel mode ipsec ipv4ではなく、多少のオーバーヘッドは掛かりますが、デフォルトのtunnel mode gre ip(DefaultなのでConfig上は表示されません)にしました。

1.構成

f:id:metonymical:20180714182611j:plain

RTAとRTBがCisco891FJとなっています。
Versionは15.7(3)M2ですが、多少古くても大丈夫だと思います。
Internetを模倣するために、RTAとRTBの間にCat3560Eを挟んでConnected同士でRoutingしています。

四の五の説明するより、Configを見てもらった方が早いと思います。

2.RTAのConfig

!
hostname RTA
!
ip cef
!
ip vrf r1
 rd 10.0.0.1:1
 route-target export 65000:1
 route-target import 65000:1
!
ip vrf r2
 rd 10.0.0.1:2
 route-target export 65000:2
 route-target import 65000:2
!
!
crypto ikev2 proposal ikev2prop
 encryption aes-cbc-256
 integrity sha256
 group 14
!
crypto ikev2 policy ikev2poli
 proposal ikev2prop
!
crypto ikev2 keyring ikev2key
 peer RTB
  address 2.2.2.2
  pre-shared-key PASSWORD
!
crypto ikev2 profile ikev2prof
 match identity remote address 2.2.2.2 255.255.255.255 
 identity local address 1.1.1.1
 authentication remote pre-share
 authentication local pre-share
 keyring local ikev2key
 lifetime 3600
!
!
crypto ipsec transform-set LAB-TS esp-aes 256 esp-sha256-hmac 
 mode tunnel
!
crypto ipsec profile LAB-ipsec-profile
 set transform-set LAB-TS
 set ikev2-profile ikev2prof
!
!
interface Tunnel100
 ip address 10.0.0.1 255.255.255.0
 mpls bgp forwarding
 mpls ip
 tunnel source 1.1.1.1
 tunnel destination 2.2.2.2
 tunnel path-mtu-discovery
 tunnel protection ipsec profile LAB-ipsec-profile
!
interface GigabitEthernet8
 ip address 1.1.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface Vlan11
 ip vrf forwarding r1
 ip address 192.168.11.1 255.255.255.0
!
interface Vlan12
 ip vrf forwarding r2
 ip address 192.168.12.1 255.255.255.0
!
!
router bgp 65000
 bgp router-id 10.0.0.1
 bgp log-neighbor-changes
 neighbor 10.0.0.2 remote-as 65001
 neighbor 10.0.0.2 update-source Tunnel100
 !
 address-family ipv4
  neighbor 10.0.0.2 activate
  neighbor 10.0.0.2 soft-reconfiguration inbound
 exit-address-family
 !
 address-family vpnv4
  neighbor 10.0.0.2 activate
  neighbor 10.0.0.2 send-community both
 exit-address-family
 !
 address-family ipv4 vrf r1
  network 192.168.11.0
 exit-address-family
 !
 address-family ipv4 vrf r2
  network 192.168.12.0
 exit-address-family
!
!
mpls ldp router-id Tunnel100
!
ip route 0.0.0.0 0.0.0.0 1.1.1.2
!

3.RTBのConfig

!
hostname RTB
!
ip cef
!
ip vrf r1
 rd 10.0.0.2:1
 route-target export 65000:1
 route-target import 65000:1
!
ip vrf r2
 rd 10.0.0.2:2
 route-target export 65000:2
 route-target import 65000:2
!
!
crypto ikev2 proposal ikev2prop
 encryption aes-cbc-256
 integrity sha256
 group 14
!
crypto ikev2 policy ikev2poli
 proposal ikev2prop
!
crypto ikev2 keyring ikev2key
 peer RTA
  address 1.1.1.1
  pre-shared-key PASSWORD
!
crypto ikev2 profile ikev2prof
 match identity remote address 1.1.1.1 255.255.255.255 
 identity local address 2.2.2.2
 authentication remote pre-share
 authentication local pre-share
 keyring local ikev2key
 lifetime 3600
!
!
crypto ipsec transform-set LAB-TS esp-aes 256 esp-sha256-hmac 
 mode tunnel
!
crypto ipsec profile LAB-ipsec-profile
 set transform-set LAB-TS
 set ikev2-profile ikev2prof
!
!
interface Tunnel100
 ip address 10.0.0.2 255.255.255.0
 mpls bgp forwarding
 mpls ip
 tunnel source 2.2.2.2
 tunnel destination 1.1.1.1
 tunnel path-mtu-discovery
 tunnel protection ipsec profile LAB-ipsec-profile
!
interface GigabitEthernet8
 ip address 2.2.2.2 255.255.255.0
 duplex auto
 speed auto
!
interface Vlan13
 ip vrf forwarding r1
 ip address 192.168.13.1 255.255.255.0
!
interface Vlan14
 ip vrf forwarding r2
 ip address 192.168.14.1 255.255.255.0
!
!
router bgp 65001
 bgp router-id 10.0.0.2
 bgp log-neighbor-changes
 neighbor 10.0.0.1 remote-as 65000
 neighbor 10.0.0.1 update-source Tunnel100
 !
 address-family ipv4
  neighbor 10.0.0.1 activate
  neighbor 10.0.0.1 soft-reconfiguration inbound
 exit-address-family
 !
 address-family vpnv4
  neighbor 10.0.0.1 activate
  neighbor 10.0.0.1 send-community both
 exit-address-family
 !
 address-family ipv4 vrf r1
  network 192.168.13.0
 exit-address-family
 !
 address-family ipv4 vrf r2
  network 192.168.14.0
 exit-address-family
!
!
mpls ldp router-id Tunnel100
!
ip route 0.0.0.0 0.0.0.0 2.2.2.1
!

以上です。

4.最後に

以下のサイトを参考にさせて頂きました。
http://www.networking-forum.com/viewtopic.php?t=28459#

今回は検証できていませんが、複数拠点で構成する場合、tunnel mode gre multipointでもイケる気がしています。そうすることで(Ciscoの)FlexVPNとしての実装もできそうな感じがします。

先にも書きましたが、tunnel mode ipsec ipv4について少々補足します。ipsec ipv4にした場合、VTI(VirtualTunnelInterface)を使用することになるため、オーバーヘッドが減少するそうです。しかし、今回の場合は、ipsec ipv4を入れると、MPLSヘッダのついたパケットがIPパケットとして(当然のことながら)認識されないためトンネルを越えられなくなります。このため、Defaultのgre ipとしています。

もう一点、rdとroute-targetについて補足します。

ip vrf r1
 rd 10.0.0.1:1
 route-target export 65000:1
 route-target import 65000:1

rdは一般的に双方のRTで合わせますが、異なっていても問題ありません。
しかし、route-targetは双方のRTで一致していないといけないため、65000:1としていますが、(router bgpに記載のASNと一致させなくてもよいという意味で)10:1とかでも問題ありません。