summaryrefslogtreecommitdiff
path: root/docs/configuration/vpn/dmvpn.rst
blob: e58eecbc01a72802552321adea5476e6476795ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
.. _vpn-dmvpn:

#####
DMVPN
#####

:abbr:`DMVPN (Dynamic Multipoint Virtual Private Network)` is a dynamic
:abbr:`VPN (Virtual Private Network)` technology originally developed by Cisco.
While their implementation was somewhat proprietary, the underlying
technologies are actually standards based. The three technologies are:

* :abbr:`NHRP (Next Hop Resolution Protocol)` :rfc:`2332`
* :abbr:`mGRE (Multipoint Generic Routing Encapsulation)` :rfc:`1702`
* :abbr:`IPSec (IP Security)` - too many RFCs to list, but start with
  :rfc:`4301`

NHRP provides the dynamic tunnel endpoint discovery mechanism (endpoint
registration, and endpoint discovery/lookup), mGRE provides the tunnel
encapsulation itself, and the IPSec protocols handle the key exchange, and
crypto mechanism.

In short, DMVPN provides the capability for creating a dynamic-mesh VPN
network without having to pre-configure (static) all possible tunnel end-point
peers.

.. note:: DMVPN only automates the tunnel endpoint discovery and setup. A
   complete solution also incorporates the use of a routing protocol. BGP is
   particularly well suited for use with DMVPN.

.. figure:: /_static/images/vpn_dmvpn_topology01.png
   :scale: 40 %
   :alt: Baseline DMVPN topology

   Baseline DMVPN topology

*************
Configuration
*************

Tunnel interface configuration
==============================

NHRP never handles routing of prefixes itself. You need to run some real routing
protocol (e.g. BGP) to advertise routes over the tunnels. What nhrpd does it
establishes ‘shortcut routes’ that optimizes the routing protocol to avoid going
through extra nodes in NBMA GRE mesh.

NHRP does route NHRP domain addresses individually using per-host prefixes.
This is similar to Cisco FlexVPN, but in contrast to opennhrp which uses
a generic subnet route.

To create NBMA GRE tunnel you might use the following:

.. code-block:: none

  set interfaces tunnel tun100 address '10.0.0.1/32'
  set interfaces tunnel tun100 enable-multicast
  set interfaces tunnel tun100 encapsulation 'gre'
  set interfaces tunnel tun100 ip adjust-mss '1360'
  set interfaces tunnel tun100 mtu '1400'
  set interfaces tunnel tun100 parameters ip key '42'
  set interfaces tunnel tun100 source-interface 'eth0'

* Please refer to the :ref:`tunnel-interface` documentation for the individual
  tunnel related options.

  .. note:: The IP-address is assigned as host prefix to tunnel interface.
    NHRP will automatically create additional host routes pointing to tunnel interface
    when a connection with these hosts is established.

The tunnel interface subnet prefix should be announced by routing protocol
from the hub nodes (e.g. BGP ‘network’ announce). This allows the routing
protocol to decide which is the closest hub and determine the relay hub on
prefix basis when direct tunnel is not established.

NHRP protocol configuration
==============================

.. cfgcmd:: set protocols nhrp tunnel <tunnel> authentication <secret>

  Enables Cisco style authentication on NHRP packets. This embeds the
  plaintext password to the outgoing NHRP packets. Maximum length of
  the password is 8 characters.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> holdtime <timeout>

  Holdtime is the number of seconds that have to pass before stopping to
  advertise an NHRP NBMA address as valid. It also controls how often NHRP
  registration requests are sent. By default registrations are sent every
  one third of the holdtime

.. cfgcmd:: set protocols nhrp tunnel <tunnel> map tunnel-ip <tunnel-ip>
  nbma <nbma-ip>

  * **tunnel-ip** - Tunnel ip address in format **x.x.x.x**.
  * **nbma-ip** - NBMA ip address in format **x.x.x.x** or **local**

  Map an IP address of a station to the station’s NBMA address.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> mtu <mtu>

  Configure NHRP advertised MTU.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> multicast <nbma-ip>

  * **nbma-ip** - NBMA ip address in format **x.x.x.x** or **dynamic**

  Sends multicast packets to the specified NBMA address. If dynamic is specified
  then destination NBMA address (or addresses) are learnt dynamically.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> network-id <network-id>

  * **network-id** - NHRP network id <1-4294967295>

  Enable NHRP on this interface and set the interface’s network ID. The network ID
  is used to allow creating multiple nhrp domains on a router when multiple interfaces
  are configured on the router. Interfaces configured with the same ID are part of the
  same logical NBMA network. The ID is a local only parameter and is not sent to other
  NHRP nodes and so IDs on different nodes do not need to match. When NHRP packets are
  received on an interface they are assigned to the local NHRP domain for that interface.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> nhs tunnel-ip <tunnel-ip> nbma <nbma-ip>

  * **tunnel-ip** - Tunnel ip address in format **x.x.x.x** or **dynamic**
  * **nbma-ip** - NBMA ip address in format **x.x.x.x**

  Configure the Next Hop Server address and its NBMA address. If dynamic is specified
  then Next Hop Server can have dynamic address which maps to its NBMA address.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> redirect

  This enable redirect replies on the NHS similar to ICMP redirects except this is
  managed by the nhrp protocol. This setting allows spokes to communicate with each
  others directly.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> registration-no-unique

  Allow the client to not set the unique flag in the NHRP packets. This is useful when
  a station has a dynamic IP address that could change over time.

.. cfgcmd:: set protocols nhrp tunnel <tunnel> shortcut

  Enable shortcut (spoke-to-spoke) tunnels to allow NHC to talk to each others directly
  after establishing a connection without going through the hub.

IPSEC configuration
==============================

* Please refer to the :ref:`ipsec` documentation for the individual IPSec
  related options.

.. note:: NHRP daemon based on FRR nhrpd. It controls IPSEC. That's why 'close-action'
  parameter in IKE configuration always is set to 'close' and 'dead-peer-detection action'
  always is set to 'clear'.

.. cfgcmd:: set vpn ipsec profile <profile-name> authentication mode pre-shared-secret

  Set preshared secret mode authentication

.. cfgcmd:: set vpn ipsec profile <profile-name> authentication pre-shared-secret <secret>

  Set preshared secret

.. cfgcmd:: set vpn ipsec profile <profile-name> bind tunnel <tunnel name>

  Bind IPSEC profile to the specific tunnel interface.

.. cfgcmd:: set vpn ipsec profile <profile-name> esp-group 'ESP-HUB'

  Map ESP group to IPSEC profile

.. cfgcmd:: set vpn ipsec profile <profile-name> ike-group 'IKE-HUB'

  Map IKE group to IPSEC profile

**********
Monitoring
**********
.. opcmd:: show ip nhrp cache

  Forwarding cache information.

.. opcmd:: show ip nhrp nhs

  Next hop server information.

.. opcmd:: show ip nhrp shortcut

  Shortcut information.

*******
Example
*******

This blueprint uses VyOS as the DMVPN Hub and Cisco IOSv 15.5(3)M and VyOS as
multiple spoke sites.

.. figure:: /_static/images/blueprint-dmvpn.png
   :width: 70%
   :align: center
   :alt: DMVPN Network Topology Diagram


   DMVPN Network Topology Diagram

Each node (Hub and Spoke) uses an IP address from the network 10.0.0.0/24.

The below referenced IP address `192.168.0.2` is used as example address
representing a global unicast address under which the HUB can be contacted by
each and every individual spoke.

.. _dmvpn:example_configuration:

Configuration
=============

Hub
---
VyOS-HUB-1
^^^^^^^^^^

.. code-block:: none

  set interfaces ethernet eth0 address '192.168.0.2/30'

  set interfaces tunnel tun100 address '10.0.0.100/32'
  set interfaces tunnel tun100 enable-multicast
  set interfaces tunnel tun100 encapsulation 'gre'
  set interfaces tunnel tun100 parameters ip key '42'
  set interfaces tunnel tun100 source-interface 'eth0'

  set protocols nhrp tunnel tun100 authentication 'test123'
  set protocols nhrp tunnel tun100 holdtime '300'
  set protocols nhrp tunnel tun100 multicast 'dynamic'
  set protocols nhrp tunnel tun100 network-id '1'
  set protocols nhrp tunnel tun100 redirect
  set protocols nhrp tunnel tun100 registration-no-unique

  set protocols static route 0.0.0.0/0 next-hop 192.168.0.1

  set vpn ipsec esp-group ESP-HUB lifetime '1800'
  set vpn ipsec esp-group ESP-HUB mode 'transport'
  set vpn ipsec esp-group ESP-HUB pfs 'dh-group2'
  set vpn ipsec esp-group ESP-HUB proposal 1 encryption 'aes256'
  set vpn ipsec esp-group ESP-HUB proposal 1 hash 'sha1'
  set vpn ipsec ike-group IKE-HUB key-exchange 'ikev1'
  set vpn ipsec ike-group IKE-HUB lifetime '3600'
  set vpn ipsec ike-group IKE-HUB proposal 1 dh-group '2'
  set vpn ipsec ike-group IKE-HUB proposal 1 encryption 'aes256'
  set vpn ipsec ike-group IKE-HUB proposal 1 hash 'sha1'
  set vpn ipsec interface 'eth0'
  set vpn ipsec profile NHRPVPN authentication mode 'pre-shared-secret'
  set vpn ipsec profile NHRPVPN authentication pre-shared-secret 'secret'
  set vpn ipsec profile NHRPVPN bind tunnel 'tun100'
  set vpn ipsec profile NHRPVPN esp-group 'ESP-HUB'
  set vpn ipsec profile NHRPVPN ike-group 'IKE-HUB'


.. note:: Setting this up on AWS will require a "Custom Protocol Rule" for
  protocol number "47" (GRE) Allow Rule in TWO places. Firstly on the VPC
  Network ACL, and secondly on the security group network ACL attached to the
  EC2 instance. This has been tested as working for the official AMI image on
  the AWS Marketplace. (Locate the correct VPC and security group by navigating
  through the details pane below your EC2 instance in the AWS console).

Spokes
------

 The individual spoke configurations only differ in interface IP addresses.

VyOS-Spoke-1 and VyOS-Spoke-2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none

  set interfaces ethernet eth0 address '192.168.1.2/30'

  set interfaces tunnel tun100 address '10.0.0.1/32'
  set interfaces tunnel tun100 enable-multicast
  set interfaces tunnel tun100 encapsulation 'gre'
  set interfaces tunnel tun100 parameters ip key '42'
  set interfaces tunnel tun100 source-interface 'eth0'

  set protocols nhrp tunnel tun100 authentication 'test123'
  set protocols nhrp tunnel tun100 holdtime '300'
  set protocols nhrp tunnel tun100 multicast 'dynamic'
  set protocols nhrp tunnel tun100 network-id '1'
  set protocols nhrp tunnel tun100 nhs tunnel-ip dynamic nbma '192.168.0.2'
  set protocols nhrp tunnel tun100 registration-no-unique
  set protocols nhrp tunnel tun100 shortcut

  set protocols static route 0.0.0.0/0 next-hop 192.168.1.1
  set protocols static route 10.0.0.0/24 next-hop 10.0.0.100

  set vpn ipsec esp-group ESP-HUB lifetime '1800'
  set vpn ipsec esp-group ESP-HUB mode 'transport'
  set vpn ipsec esp-group ESP-HUB pfs 'dh-group2'
  set vpn ipsec esp-group ESP-HUB proposal 1 encryption 'aes256'
  set vpn ipsec esp-group ESP-HUB proposal 1 hash 'sha1'
  set vpn ipsec ike-group IKE-HUB key-exchange 'ikev1'
  set vpn ipsec ike-group IKE-HUB lifetime '3600'
  set vpn ipsec ike-group IKE-HUB proposal 1 dh-group '2'
  set vpn ipsec ike-group IKE-HUB proposal 1 encryption 'aes256'
  set vpn ipsec ike-group IKE-HUB proposal 1 hash 'sha1'
  set vpn ipsec interface 'eth0'
  set vpn ipsec profile NHRPVPN authentication mode 'pre-shared-secret'
  set vpn ipsec profile NHRPVPN authentication pre-shared-secret 'secret'
  set vpn ipsec profile NHRPVPN bind tunnel 'tun100'
  set vpn ipsec profile NHRPVPN esp-group 'ESP-HUB'
  set vpn ipsec profile NHRPVPN ike-group 'IKE-HUB'

Cisco-Spoke-3
^^^^^^^^^^^^^

.. code-block:: none

  crypto isakmp policy 10
   encr aes 256
   authentication pre-share
   group 2
   lifetime 3600
  crypto isakmp key secret address 0.0.0.0
  !
  !
  crypto ipsec transform-set DMVPNESP esp-aes 256 esp-sha-hmac
   mode transport
  !
  crypto ipsec profile DMVPNPROFILE
   set security-association lifetime seconds 1800
   set transform-set DMVPNESP
   set pfs group2
  !
  !
  !
  !
  !
  !
  !
  interface Tunnel100
   ip address 10.0.0.3 255.255.255.0
   no ip redirects
   ip nhrp authentication test123
   ip nhrp map multicast dynamic
   ip nhrp network-id 1
   ip nhrp holdtime 300
   ip nhrp nhs 10.0.0.100 nbma 192.168.0.2
   ip nhrp registration no-unique
   ip nhrp redirect
  tunnel source GigabitEthernet0/0
   tunnel mode gre multipoint
   tunnel key 42
   tunnel protection ipsec profile DMVPNPROFILE
  !
  interface GigabitEthernet0/0
   ip address 192.168.3.2 255.255.255.252
   duplex auto
   speed auto
   media-type rj45
  !
  ip route 0.0.0.0 0.0.0.0 192.168.3.1


Monitoring DMVPN Network
^^^^^^^^^^^^^^^^^^^^^^^^

Let send ICMP packets from VyOS-SPOKE-1 to Cisco-SPOKE-3

.. code-block:: none

  vyos@vyos:~$ ping 10.0.0.3
  PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
  64 bytes from 10.0.0.3: icmp_seq=1 ttl=255 time=3.44 ms
  64 bytes from 10.0.0.3: icmp_seq=2 ttl=255 time=3.07 ms
  ^C
  --- 10.0.0.3 ping statistics ---
  2 packets transmitted, 2 received, 0% packet loss, time 1002ms
  rtt min/avg/max/mdev = 3.072/3.257/3.442/0.185 ms

Monitoring on HUB
^^^^^^^^^^^^^^^^^

.. code-block:: none

  vyos@vyos:~$ show ip nhrp cache
  Iface    Type     Protocol                 NBMA                     Claimed NBMA             Flags  Identity
  tun100   dynamic  10.0.0.1                 192.168.1.2              192.168.1.2               T     192.168.1.2
  tun100   dynamic  10.0.0.3                 192.168.3.2              192.168.3.2               T     192.168.3.2
  tun100   dynamic  10.0.0.2                 192.168.2.2              192.168.2.2               T     192.168.2.2
  tun100   local    10.0.0.100               192.168.0.2              192.168.0.2                     -

  vyos@vyos:~$ show vpn ipsec sa
  Connection                  State    Uptime    Bytes In/Out    Packets In/Out    Remote address    Remote ID    Proposal
  --------------------------  -------  --------  --------------  ----------------  ----------------  -----------  ----------------------------------
  dmvpn-NHRPVPN-tun100-child  up       3m46s     230B/270B       2/2               192.168.1.2       192.168.1.2  AES_CBC_256/HMAC_SHA1_96/MODP_1024
  dmvpn-NHRPVPN-tun100-child  up       5m48s     460B/540B       4/4               192.168.2.2       192.168.2.2  AES_CBC_256/HMAC_SHA1_96/MODP_1024
  dmvpn-NHRPVPN-tun100-child  up       16m26s    1K/1K           13/12             192.168.3.2       192.168.3.2  AES_CBC_256/HMAC_SHA1_96/MODP_1024

Monitoring on Spokes
^^^^^^^^^^^^^^^^^^^^

.. code-block:: none

  vyos@vyos:~$ show ip nhrp cache
  Iface    Type     Protocol                 NBMA                     Claimed NBMA             Flags  Identity
  tun100   local    10.0.0.1                 192.168.1.2              192.168.1.2                     -
  tun100   dynamic  10.0.0.3                 192.168.3.2              192.168.3.2               T     192.168.3.2
  tun100   nhs      10.0.0.100               192.168.0.2              192.168.0.2               T     192.168.0.2

  vyos@vyos:~$ show ip nhrp nhs
  Iface    FQDN                     NBMA             Protocol
  tun100   192.168.0.2              192.168.0.2      10.0.0.100

  vyos@vyos:~$ show ip nhrp shortcut
  Type     Prefix                   Via                      Identity
  dynamic  10.0.0.3/32              10.0.0.3                 192.168.3.2

  vyos@vyos:~$ show vpn ipsec sa
  Connection                  State    Uptime    Bytes In/Out    Packets In/Out    Remote address    Remote ID    Proposal
  --------------------------  -------  --------  --------------  ----------------  ----------------  -----------  ----------------------------------
  dmvpn-NHRPVPN-tun100-child  up       6m43s     898B/695B       7/6               192.168.0.2       192.168.0.2  AES_CBC_256/HMAC_SHA1_96/MODP_1024
  dmvpn-NHRPVPN-tun100-child  up       49s       215B/187B       2/2               192.168.3.2       192.168.3.2  AES_CBC_256/HMAC_SHA1_96/MODP_1024