この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
こんにちは、菊池です。
Azure VNetへのVPN接続を検証しています。以前、以下の記事にてスタティックルーティンングでのVPN接続を紹介しています。
今回は、これに追加してBGPでのルーティングまで確認を行いたいと思います。
構成
構成イメージは以下の通りです。接続に利用するルータは、前述の記事と同じ Cisco C841Mです。
- Azure VNetのネットワーク:172.16.0.0/16
- GatewaySubnet:172.16.1.0/24
- オンプレネットワーク:10.10.10.0/24
- ローカルネットワークゲートウェイのVPN接続インターフェースのIP:192.168.1.253
VPN接続ルータ(ローカルネットワークゲートウェイ)は直接インターネットには接続せず、ルータを挟んで192.168.1.253のIPを割り当てています。NATトラバーサルにてVPN接続します。Azure側のVNet、サブネットは作成済みの状態です。
VPN接続とBGP設定
まずは、仮想ネットワークゲートウェイの作成です。Azure Potalから、仮想ネットワークゲートウェイの作成に進みます。
パラメータの設定です。BGPによる動的ルーティングを利用するためには、ルートベースのVPNと、VpnGw1以上(Basic以外)のSKUを選択する必要があります。BGP ASNを有効にし、ASNを設定します(既定の値で問題ありません)。また、今回はシングル接続のため、アクティブ/アクティブモードは無効とします。
パラメータを確認し、作成します。
次に、オンプレ側のVPN接続先となる、ローカルゲートウェイの作成です。オンプレ側のパブリックIPとBGP設定の構成にチェックを入れます。ASNは、仮想ネットワークゲートウェイと異なる値を入れましょう。BGPピアのIPアドレスは、VPNルータのトンネルインターフェースに割り当てるIPアドレスです。通信経路上のネットワークとは異なるプライベートIPアドレスを指定します。
仮想ネットワークゲートウェイとローカルネットワークゲートウェイが作成されたら、接続の追加です。仮想ネットワークゲートウェイから、[接続] -> [追加] へと進みます。
接続の種類には [サイト対サイト]、共有キーは認証に使用する文字列を指定します。IKEはv2を選択しました(既定)。
接続が作成されたら、[構成] からBGPを有効化する必要があります。
オンプレ側のVPNルーターに設定するためのサンプルコンフィグをダウンロードします。[構成のダウンロード] から、ベンダー、デバイスファミリ、バージョンを選択してダウンロードします。
ダウンロードしたコンフィグを必要に応じて編集し、ルータに設定します。主に、以下の点について設定が必要です。(記事の末尾に、ダウンロードした設定ファイルを記載します)
- VPNに利用するIPアドレスが、ローカルネットワークゲートウェイに指定したパブリックアドレスになってます。今回は、VPNルータはインターネット接続用ルータと別構成で、LAN内にあるため、プライベートIPに書き換えます。
- VPN接続のインターフェースおよびLAN側インターフェースが、それぞれ
GigabitEthernet0/0
、GigabitEthernet0/1
となっていますので、実際の構成に合わせて書き換えます。 - BGPで広報するルートがブランクになっていますので、オンプレ側の必要な経路に書き換えます。
デフォルト
router bgp 65000
bgp log-neighbor-changes
neighbor 172.16.1.254 remote-as 65515
neighbor 172.16.1.254 ebgp-multihop 255
neighbor 172.16.1.254 update-source Tunnel100
!
address-family ipv4
network "INSERT LAN BGP ROUTE HERE" mask "INSERT BGP ROUTE SUBNET MASK HERE"
network "INSERT LAN BGP ROUTE HERE" mask "INSERT BGP ROUTE SUBNET MASK HERE"
! etc...
neighbor 172.16.1.254 activate
exit-address-family
書き換え後。10.10.10.0/24
と10.212.134.0/24
を広報するように設定しました。
router bgp 65000
bgp log-neighbor-changes
neighbor 172.16.1.254 remote-as 65515
neighbor 172.16.1.254 ebgp-multihop 255
neighbor 172.16.1.254 update-source Tunnel100
address-family ipv4
network 10.10.10.0 mask 255.255.255.0
network 10.212.134.0 mask 255.255.255.0
neighbor 172.16.1.254 activate
exit-address-family
- BGPピアとなる仮想プライベートゲートウェイへのスタティックルートを追加します。
ip route 172.16.1.254 255.255.255.255 Tunnel100
上記設定を実施し、問題なければIPSecがアップし、BGPによる経路交換が行われます。接続を確認すると、[接続済み] のステータスになっています。
ルータ側でBGPの状態を確認すると、VNetのネットワークを受け取っていることが確認できます。
#show ip bgp
BGP table version is 6, local router ID is 192.168.255.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.10.10.0/24 0.0.0.0 0 32768 i
*> 10.212.134.0/24 10.10.10.253 0 32768 i
*> 172.16.0.0 172.16.1.254 0 65515 i
#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
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
B 172.16.0.0/16 [20/0] via 172.16.1.254, 14:14:55
S 172.16.1.254/32 is directly connected, Tunnel100
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
192.168.255.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.255.0/31 is directly connected, Tunnel100
L 192.168.255.1/32 is directly connected, Tunnel100
Azure Portalからも、BGPで受け取った経路が有効であることが確認できます。
これで、Azure VNetへのSite to Site VPNが接続され、BGPによる経路交換を確認できました。念のため、オンプレ側からVNet内のVMへ、SSHで接続確認します。
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:63:84:21 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.201/24 brd 10.10.10.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::5bb0:a9d4:9ef1:337e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
$ ssh 172.16.0.5
skikuchi@172.16.0.5's password:
Last login: Tue Jun 16 10:13:15 2020 from 10.10.10.201
$
無事、接続できました。
まとめ
AzureとのVPN接続における、BGPのルーティングを試しました。BGPパラメータの設定に加え、接続単位で有効化が必要になるので見逃さないようにしましょう。
参考
ダウンロードしたサンプルコンフィグの全文です。(バプリックIPはマスクしています)
! Microsoft Corporation
! --------------------------------------------------------------------------------------------------------------------------------------------
! Generic configuration templates
!
! DISCLAIMER : THIS IS A SAMPLE CONFIGURATION SCRIPT OFFERED BY MICROSOFT FOR YOUR 3RD PARTY DEVICE. IF YOU NEED
! HANDS-ON SUPPORT OR FURTHER ASSISTANCE, PLEASE CONTACT YOUR VENDOR DIRECTLY.
!
! This configuration template shows all the VPN configuration parameters associated with your S2S VPN connection.
! The script you need to copy onto your Cisco ISR SRX (IOS 15.2+) to setup a RouteBased IKEv2 VPN Tunnel to Azure (with BGP) is found below [#11]
! --------------------------------------------------------------------------------------------------------------------------------------------
! [1] Resource names
! CONNECTION NAME : This field is the name of your connection resource
! VIRTUAL NETWORK GATEWAY : The name of your Azure VPN gateway resource for the connection
! LOCAL NETWORK GATEWAY : The name of your local network gateway resource for the connection
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/CONNECTION_NAME = test
/Data/VNG_NAME = b819006d-97c1-4337-ab09-0ead63ce8cb5
/Data/LNG_NAME = home-gw
! [2] Public IP address of the Azure VPN gateway
! Active-Standby VPN gateway (single public IP address)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/VNG_GATEWAYIP = 20.xxx.xxx.xxx
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Active-Active VPN gateway (A/A mode if more than one public IP is listed below)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/VNG_GATEWAYIPS/IpAddress/IP = 20.xxx.xxx.xxx
! [3] Public IP address of the on-premises VPN device
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/LNG_GATEWAYIP = 222.xxx.xxx.xxx
! [4] VNet address prefixes: a list of all VNet address prefixes in different formats
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/VnetSubnets/Subnet/SP_NetworkIpRange = 172.16.0.0
SP_NetworkSubnetMask = 255.255.0.0
SP_NetworkWildcardBits = 0.0.255.255
SP_NetworkCIDR = 172.16.0.0/16
SP_TunnelName = SP_TunnelName
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! [5] On-premises address prefixes: a list of all on-premises address prefixes defined in LNG
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! [6] Phase 1/Main Mode:
! IKE encryption algorithm
! IKE hashing algorithm
! IKE Diffie-Hellman group
! IKE SA lifetime (seconds)
! IKE SA data size (Kilobytes)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/IKE_ENCRYPTION_1 = AES256
/Data/IKE_INTEGRITY_1 = SHA256
/Data/IKE_DHGROUP_1 = DHGroup2
/Data/IKE_SALIFETIME_1 = 28800
! [7] Phase 2/Quick Mode:
! IPsec encryption algorithm
! IPsec hashing algorithm
! PFS Group (Perfect Forward Secrecy)
! IPsec SA (QMSA) lifetime (seconds)
! IPsec SA (QMSA) lifetime (kilobytes)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/IPsec_ENCRYPTION_1 = AES256
/Data/IPsec_INTEGRITY_1 = SHA256
/Data/IPsec_PFSGROUP_1 = None
/Data/IPsec_SALIFETIME = 3600
/Data/IPsec_KB_SALIFETIME = 102400000
! [8] Connection pre-shared key
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/CONNECTION_PSK = vc8NkyUYpuuLYzZ6NWGocK2c
! [9] BGP parameters - Azure VPN gateway
! Enable BGP
! BGP ASN for Azure VPN gateway
! BGP speaker IP address for the Azure VPN gateway
! BGP peer IP address(es)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/CONNECTION_BGP_ENABLED = True
/Data/VNG_ASN = 65515
/Data/VNG_BGPIP = 172.16.1.254
/Data/VNG_BGPIPS/IpAddress/IP = 172.16.1.254
! [10] BGP parameters - on-premises network / LNG
! BGP ASN for the on-premises network
! BGP speaker IP address for the on-premises network
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/LNG_ASN = 65000
/Data/LNG_BGPIP = 192.168.255.1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Data/BGPSubnets/Subnet/SP_NetworkIpRange = 172.16.1.254
SP_NetworkSubnetMask = 255.255.255.255
SP_NetworkWildcardBits = 0.0.0.0
SP_NetworkCIDR = 172.16.1.254/32
SP_TunnelName = 20.xxx.xxx.xxx
! [11] Misc
! NOTE: REPLACE these miscellaneous variables on the script below values as necessary, some devices may have overlapping identifiers for other pre-configured VPN tunnels/policies
!=================================================================================
/Data/AccessList = Azure-ACL-test
/Data/Outside_Interface_Name = GigabithEthernet0/0
/Data/Inside_Interface_Name = GigabithEthernet0/1
!=================================================================================
! ---------------------------------------------------------------------------------------------------------------------
! ACL rules
!
! Some VPN devices require explicit ACL rules to allow cross-premises traffic towards Azure:
! Ensure all the lines below under the network objects are single-spaced.
object-group network AzureNetworks
description Azure-Virtual-Networks
network-object 172.16.0.0 255.255.0.0
exit
object-group network OnpremisesNetworks
description Onpremises-Networks
exit
access-list Azure-ACL-test permit 20.xxx.xxx.xxx log
access-list Azure-ACL-test permit object-group AzureNetworks log
access-list Azure-ACL-test permit object-group OnpremisesNetworks log
! ---------------------------------------------------------------------------------------------------------------------
! IKEv2 PROPOSAL
crypto ikev2 proposal azure-proposal-test
encryption aes-cbc-256 aes-cbc-128
integrity sha1 sha256
group 2
!
!
! ---------------------------------------------------------------------------------------------------------------------
! IKEv2 POLICY
crypto ikev2 policy azure-policy-test
proposal azure-proposal-test
!
!
! ---------------------------------------------------------------------------------------------------------------------
! IKEv2 KEYRING (PRE-SHARED KEY)
crypto ikev2 keyring azure-keyring-test
peer 20.xxx.xxx.xxx
address 20.xxx.xxx.xxx
pre-shared-key vc8NkyUYpuuLYzZ6NWGocK2c
!
!
!
! ---------------------------------------------------------------------------------------------------------------------
! IKEv2 PROFILE
! NOTE: Interface 'GigabitEthernet0/0' was picked as the LAN interface where on-Premises networks are connected.
! REPLACE as needed.
crypto ikev2 profile azure-profile-test
match address local interface GigabitEthernet0/0
match identity remote address 20.xxx.xxx.xxx 255.255.255.255
authentication local pre-share
authentication remote pre-share
keyring local azure-keyring
lifetime 28800
dpd 10 5 on-demand
!
!
! ---------------------------------------------------------------------------------------------------------------------
! IPSEC TRANSFORM
crypto ipsec transform-set azure-ipsec-proposal-set esp-aes 256 esp-sha256-hmac
!
crypto ipsec profile azure-ipsec-profile-test
set security-association lifetime kilobytes 102400000
set transform-set azure-ipsec-proposal-set
set ikev2-profile azure-profile-test
!
!
! ---------------------------------------------------------------------------------------------------------------------
! TUNNEL INTERFACE FOR ROUTEBASED ROUTING TO AZURE
! Note: 'Tunnel100' was picked as an arbitrary interface name.
! REPLACE as needed.
interface Tunnel100
ip address 192.168.255.1 255.255.255.254
ip tcp adjust-mss 1350
tunnel source 222.xxx.xxx.xxx
tunnel mode ipsec ipv4
tunnel destination 20.xxx.xxx.xxx
tunnel protection ipsec profile azure-ipsec-profile-test
!
! ---------------------------------------------------------------------------------------------------------------------
! WAN INTERFACE (WHERE THE PUBLIC IP OF CISCO ISR PORT IS LOCATED)
! NOTE: REPLACE the interface name ('GigabitEthernet0/0') as needed.
! REPLACE the WAN public (ISP) IP subnet as needed. In this example, it's '255.255.252.0', denoting a /22 ISP Public IP subnet
interface GigabitEthernet0/0
description OUTSIDE
ip address 222.xxx.xxx.xxx 255.255.252.0
duplex auto
speed auto
no cdp enable
!
! ---------------------------------------------------------------------------------------------------------------------
! LAN INTERFACE (WHERE THE ONPREMISES NETWORKS ARE LOCATED)
! NOTE: REPLACE the interface name ('GigabitEthernet0/1') as needed.
! Insert your LAN Port IP as well as your LAN mask below, as configured on your device.
interface GigabitEthernet0/1
ip address "INSERT_LAN-PORT_IP_HERE" "INSERT_LAN_MASK_HERE"
duplex auto
speed auto
no cdp enable
no mop enabled
!
! ---------------------------------------------------------------------------------------------------------------------
! BGP ROUTER CONFIGURATION
! NOTE: Change your LAN BGP Advertisements (under the IPV4 Addr Family) as needed for your tunnel
router bgp 65000
bgp log-neighbor-changes
neighbor 172.16.1.254 remote-as 65515
neighbor 172.16.1.254 ebgp-multihop 255
neighbor 172.16.1.254 update-source Tunnel100
!
address-family ipv4
network "INSERT LAN BGP ROUTE HERE" mask "INSERT BGP ROUTE SUBNET MASK HERE"
network "INSERT LAN BGP ROUTE HERE" mask "INSERT BGP ROUTE SUBNET MASK HERE"
! etc...
neighbor 172.16.1.254 activate
exit-address-family
!
ip forward-protocol nd
!
! ---------------------------------------------------------------------------------------------------------------------
! STATIC ROUTES TO ENSURE AZURE-SPECIFIC TRAFFIC CROSSES THE TUNNEL INTERFACE BEFORE GETTING OUTSIDE
! NOTE: UPDATE the routes as needed.
! If you are going through an ISP default gateway, make sure that IP is reflected under the general traffic going through the WAN instead (Line 1 below).
ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0 222.xxx.xxx.xxx
ip route Tunnel100
! OPTIONAL
no service-routing capabilities-manager