summaryrefslogtreecommitdiff
path: root/docs/configexamples/dual-hub-dmvpn.rst
blob: f2d0939186e53eb1cdaae5ab5d43fea8136ba346 (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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258

########################
Dual-Hub DMVPN with VyOS
########################

DMVPN is a Dynamic Multipoint VPN technology that provides the capability 
for creating a dynamic-mesh VPN network without having to pre-configure 
(static) all possible tunnel end-point peers those simplifying deployment 
and management of the newly added remote sites. There are 3 main protocols 
primarily used to implement DMVPN:

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

For this example we are using the following devices:

* 2 x Hubs
* 3 x Spokes
* 1 x Client device (VPC)
* 1 x ISP router

The following software was used in the creation of this document:

* Operating system: VyOS
* Version: 1.3-beta-202112090443
* Image name: vyos-1.3-beta-202112090443-amd64.iso



********
Topology
********
.. image:: /_static/images/VyOS_Dual-Hub_DMVPN.png
   :width: 80%
   :align: center
   :alt: Network Topology Diagram



******************************************
Network Addressing and Protocol Parameters
******************************************

The following ip addressing schema used for the devices IPv4 connectivity:

+-----------------------------------------------------------------------------+
|10.X1.0.0/30 - p2p Hubs to ISP networks, where X is Hub site number          |
+-----------------------------------------------------------------------------+
|10.Y1.1.0/24 - p2p Spokes to ISP networks(DHCP), where Y is Spoke site number|
+-----------------------------------------------------------------------------+
|172.16.253.0/29 - tunnels addressing for Hub-1 connections                   |
+-----------------------------------------------------------------------------+
|172.16.254.0/29 - tunnels addressing for Hub-2 connections                   |
+-----------------------------------------------------------------------------+
|192.168.0.0/24 - HQ site local network                                       |
+-----------------------------------------------------------------------------+
|192.168.Z.0/24 - remote sites local network, where Z is Spoke site number    |
+-----------------------------------------------------------------------------+

eBGP parameters for the routers:

+----------------------------------------------+
|AS65000 - HQ (Hub-1 and Hub-2)                |
+----------------------------------------------+
|AS6500X - Spokes, where X is Spoke site number|
+----------------------------------------------+



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



Step-1: Basic connectivity configuration
========================================

- Hub-1:

.. code-block:: none
   
    set interfaces ethernet eth0 address '10.11.0.1/30'
    set interfaces ethernet eth1 address '192.168.0.1/24'
    set protocols static route 0.0.0.0/0 next-hop 10.11.0.2
    set system host-name 'Hub-1'

- Hub-2:

.. code-block:: none
   
    set interfaces ethernet eth0 address '10.21.0.1/30'
    set interfaces ethernet eth1 address '192.168.0.2/24'
    set protocols static route 0.0.0.0/0 next-hop 10.21.0.2
    set system host-name 'Hub-2'

- Spoke-1:

.. code-block:: none
   
    set interfaces ethernet eth0 address 'dhcp'
    set interfaces ethernet eth1 address '192.168.1.1/24'
    set system host-name 'Spoke-1'

- Spoke-2:

.. code-block:: none
   
    set interfaces ethernet eth0 address 'dhcp'
    set interfaces ethernet eth1 address '192.168.2.1/24'
    set system host-name 'Spoke-2'
    
- Spoke-3:

.. code-block:: none
   
    set interfaces ethernet eth0 address 'dhcp'
    set interfaces ethernet eth1 address '192.168.3.1/24'
    set system host-name 'Spoke-3'
    
- ISP-1:

.. code-block:: none
   
    set interfaces ethernet eth0 address '10.11.0.2/30'
    set interfaces ethernet eth1 address '10.21.0.2/30'
    set interfaces ethernet eth2 address '10.31.1.1/24'
    set interfaces ethernet eth3 address '10.21.1.1/24'
    set interfaces ethernet eth4 address '10.11.1.1/24'
    set service dhcp-server shared-network-name SPK-1 authoritative
    set service dhcp-server shared-network-name SPK-1 subnet 10.11.1.0/24 default-router '10.11.1.1'
    set service dhcp-server shared-network-name SPK-1 subnet 10.11.1.0/24 range 1 start '10.11.1.10'
    set service dhcp-server shared-network-name SPK-1 subnet 10.11.1.0/24 range 1 stop '10.11.1.100'
    set service dhcp-server shared-network-name SPK-2 authoritative
    set service dhcp-server shared-network-name SPK-2 subnet 10.21.1.0/24 default-router '10.21.1.1'
    set service dhcp-server shared-network-name SPK-2 subnet 10.21.1.0/24 range 1 start '10.21.1.10'
    set service dhcp-server shared-network-name SPK-2 subnet 10.21.1.0/24 range 1 stop '10.21.1.100'
    set service dhcp-server shared-network-name SPK-3 authoritative
    set service dhcp-server shared-network-name SPK-3 subnet 10.31.1.0/24 default-router '10.31.1.1'
    set service dhcp-server shared-network-name SPK-3 subnet 10.31.1.0/24 range 1 start '10.31.1.10'
    set service dhcp-server shared-network-name SPK-3 subnet 10.31.1.0/24 range 1 stop '10.31.1.100'
    set system host-name 'ISP1'



Step-2: VRRP configuration for HQ Local network redundancy
==========================================================

Here we are using VRRP as a local redundancy protocol between Hub-1 and Hub-2.
Initially, Hub-1 operates as an Active and Hub-2 as a Standby router.
Additionally, health-check and script are used to track uplinks and properly 
switch mastership between Hub nodes based on the upstream router 
reachability (ISP-1). **Note, that before adding local paths to the scripts into 
configuration, you have to create and make them executable first**.

Hub-1 and Hub-2 VRRP health-check script:
_________________________________________

* /config/scripts/vrrp-check.sh

.. code-block:: none
    
    #!/bin/bash

    eth0status="$(cat /sys/class/net/eth0/operstate | grep 'up')"
    
    if [[ ! -z ${eth0status} ]]; then
     eth0gw="$(ip -j r show 0.0.0.0/0 dev eth0 | awk 'match($0, /\"gateway":\"([[:digit:]\.]+)/, gw) {print gw[1]}')"
     if [[ ! -z $eth0gw ]]; then
      /bin/ping -I eth0 -c 1 -W 1 $eth0gw && exit 0 || exit 1
     else
      exit 1
     fi
    else
     #Exit 0 because eth0 down is handled by vrrp transition
     exit 0
    fi


**Note**: some parts of the script might be dependent on your network topology 
and connectivity. Be careful before using it on your own devices.


Hub-1 and Hub-2 VRRP configuration:
___________________________________

* Hub-1

.. code-block:: none
   
    set high-availability vrrp group HQ health-check failure-count '3'
    set high-availability vrrp group HQ health-check interval '1'
    set high-availability vrrp group HQ health-check script '/config/scripts/vrrp-check.sh'
    set high-availability vrrp group HQ interface 'eth1'
    set high-availability vrrp group HQ no-preempt
    set high-availability vrrp group HQ priority '200'
    set high-availability vrrp group HQ rfc3768-compatibility
    set high-availability vrrp group HQ virtual-address '192.168.0.254/24'
    set high-availability vrrp group HQ vrid '1'

* Hub-2:

.. code-block:: none
    
    set high-availability vrrp group HQ health-check failure-count '3'
    set high-availability vrrp group HQ health-check interval '1'
    set high-availability vrrp group HQ health-check script '/config/scripts/vrrp-check.sh'
    set high-availability vrrp group HQ interface 'eth1'
    set high-availability vrrp group HQ no-preempt
    set high-availability vrrp group HQ priority '100'
    set high-availability vrrp group HQ rfc3768-compatibility
    set high-availability vrrp group HQ virtual-address '192.168.0.254/24'
    set high-availability vrrp group HQ vrid '1'



Step-3: DMVPN configuration between Hub and Spoke devices
=========================================================

This section provides an example configuration of the DMVPN enabled devices. 
Hub devices are configured with static IPv4 addresses on the uplink interfaces 
while Spoke devices receive addresses dynamically from a pre-defined DHCP 
pool configured on ISP router. For redundancy purposes, we use 1 tunnel 
interface on each Hub device and 2 tunnel interfaces on Spoke devices 
destined to each of the Hubs. For the optimal tunnel operation timers are 
significantly decreased and set to the following values:

**NHRP** tunnel holding time - 30 seconds

**IKE DPD** enabled with "restart" action set, interval 3 and timeout 
30 seconds

**Note**: these values are used only for the lab demonstration and may not 
suit exclusive production networks.

- Hub-1:

.. code-block:: none
   
    set interfaces tunnel tun100 address '172.16.253.134/29'
    set interfaces tunnel tun100 encapsulation 'gre'
    set interfaces tunnel tun100 multicast 'enable'
    set interfaces tunnel tun100 parameters ip key '1'
    set interfaces tunnel tun100 source-address '10.11.0.1'
    
    set protocols nhrp tunnel tun100 cisco-authentication 'secret'
    set protocols nhrp tunnel tun100 holding-time '30'
    set protocols nhrp tunnel tun100 multicast 'dynamic'
    set protocols nhrp tunnel tun100 redirect
    set protocols nhrp tunnel tun100 shortcut
    
    set vpn ipsec esp-group ESP-HUB compression 'disable'
    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 esp-group ESP-HUB proposal 2 encryption '3des'
    set vpn ipsec esp-group ESP-HUB proposal 2 hash 'md5'
    set vpn ipsec ike-group IKE-HUB close-action 'none'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection action 'restart'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection interval '3'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection timeout '30'
    set vpn ipsec ike-group IKE-HUB ikev2-reauth 'no'
    set vpn ipsec ike-group IKE-HUB key-exchange 'ikev2'
    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 ike-group IKE-HUB proposal 2 dh-group '2'
    set vpn ipsec ike-group IKE-HUB proposal 2 encryption 'aes128'
    set vpn ipsec ike-group IKE-HUB proposal 2 hash 'sha1'
    set vpn ipsec ipsec-interfaces 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'

- Hub-2:

.. code-block:: none
   
    set interfaces tunnel tun100 address '172.16.254.134/29'
    set interfaces tunnel tun100 encapsulation 'gre'
    set interfaces tunnel tun100 multicast 'enable'
    set interfaces tunnel tun100 parameters ip key '2'
    set interfaces tunnel tun100 source-address '10.21.0.1'
    
    set protocols nhrp tunnel tun100 cisco-authentication 'secret'
    set protocols nhrp tunnel tun100 holding-time '30'
    set protocols nhrp tunnel tun100 multicast 'dynamic'
    set protocols nhrp tunnel tun100 redirect
    set protocols nhrp tunnel tun100 shortcut
    
    set vpn ipsec esp-group ESP-HUB compression 'disable'
    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 esp-group ESP-HUB proposal 2 encryption '3des'
    set vpn ipsec esp-group ESP-HUB proposal 2 hash 'md5'
    set vpn ipsec ike-group IKE-HUB close-action 'none'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection action 'restart'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection interval '3'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection timeout '30'
    set vpn ipsec ike-group IKE-HUB ikev2-reauth 'no'
    set vpn ipsec ike-group IKE-HUB key-exchange 'ikev2'
    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 ike-group IKE-HUB proposal 2 dh-group '2'
    set vpn ipsec ike-group IKE-HUB proposal 2 encryption 'aes128'
    set vpn ipsec ike-group IKE-HUB proposal 2 hash 'sha1'
    set vpn ipsec ipsec-interfaces 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'
    
- Spoke-1:

.. code-block:: none
   
    set interfaces tunnel tun100 address '172.16.253.131/29'
    set interfaces tunnel tun100 encapsulation 'gre'
    set interfaces tunnel tun100 multicast 'enable'
    set interfaces tunnel tun100 parameters ip key '1'
    set interfaces tunnel tun100 source-address '0.0.0.0'
    set interfaces tunnel tun200 address '172.16.254.131/29'
    set interfaces tunnel tun200 encapsulation 'gre'
    set interfaces tunnel tun200 multicast 'enable'
    set interfaces tunnel tun200 parameters ip key '2'
    set interfaces tunnel tun200 source-address '0.0.0.0'
    
    set protocols nhrp tunnel tun100 cisco-authentication 'secret'
    set protocols nhrp tunnel tun100 holding-time '30'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 nbma-address '10.11.0.1'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 register
    set protocols nhrp tunnel tun100 multicast 'nhs'
    set protocols nhrp tunnel tun100 redirect
    set protocols nhrp tunnel tun100 shortcut
    set protocols nhrp tunnel tun200 cisco-authentication 'secret'
    set protocols nhrp tunnel tun200 holding-time '30'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 nbma-address '10.21.0.1'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 register
    set protocols nhrp tunnel tun200 multicast 'nhs'
    set protocols nhrp tunnel tun200 redirect
    set protocols nhrp tunnel tun200 shortcut
    
    set vpn ipsec esp-group ESP-HUB compression 'disable'
    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 esp-group ESP-HUB proposal 2 encryption '3des'
    set vpn ipsec esp-group ESP-HUB proposal 2 hash 'md5'
    set vpn ipsec ike-group IKE-HUB close-action 'none'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection action 'restart'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection interval '3'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection timeout '30'
    set vpn ipsec ike-group IKE-HUB ikev2-reauth 'no'
    set vpn ipsec ike-group IKE-HUB key-exchange 'ikev2'
    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 ike-group IKE-HUB proposal 2 dh-group '2'
    set vpn ipsec ike-group IKE-HUB proposal 2 encryption 'aes128'
    set vpn ipsec ike-group IKE-HUB proposal 2 hash 'sha1'
    set vpn ipsec ipsec-interfaces 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 bind tunnel 'tun200'
    set vpn ipsec profile NHRPVPN esp-group 'ESP-HUB'
    set vpn ipsec profile NHRPVPN ike-group 'IKE-HUB'
    
- Spoke-2:

.. code-block:: none
   
    set interfaces tunnel tun100 address '172.16.253.132/29'
    set interfaces tunnel tun100 encapsulation 'gre'
    set interfaces tunnel tun100 multicast 'enable'
    set interfaces tunnel tun100 parameters ip key '1'
    set interfaces tunnel tun100 source-address '0.0.0.0'
    set interfaces tunnel tun200 address '172.16.254.132/29'
    set interfaces tunnel tun200 encapsulation 'gre'
    set interfaces tunnel tun200 multicast 'enable'
    set interfaces tunnel tun200 parameters ip key '2'
    set interfaces tunnel tun200 source-address '0.0.0.0'
    
    set protocols nhrp tunnel tun100 cisco-authentication 'secret'
    set protocols nhrp tunnel tun100 holding-time '30'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 nbma-address '10.11.0.1'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 register
    set protocols nhrp tunnel tun100 multicast 'nhs'
    set protocols nhrp tunnel tun100 redirect
    set protocols nhrp tunnel tun100 shortcut
    set protocols nhrp tunnel tun200 cisco-authentication 'secret'
    set protocols nhrp tunnel tun200 holding-time '30'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 nbma-address '10.21.0.1'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 register
    set protocols nhrp tunnel tun200 multicast 'nhs'
    set protocols nhrp tunnel tun200 redirect
    set protocols nhrp tunnel tun200 shortcut
    
    set vpn ipsec esp-group ESP-HUB compression 'disable'
    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 esp-group ESP-HUB proposal 2 encryption '3des'
    set vpn ipsec esp-group ESP-HUB proposal 2 hash 'md5'
    set vpn ipsec ike-group IKE-HUB close-action 'none'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection action 'restart'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection interval '3'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection timeout '30'
    set vpn ipsec ike-group IKE-HUB ikev2-reauth 'no'
    set vpn ipsec ike-group IKE-HUB key-exchange 'ikev2'
    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 ike-group IKE-HUB proposal 2 dh-group '2'
    set vpn ipsec ike-group IKE-HUB proposal 2 encryption 'aes128'
    set vpn ipsec ike-group IKE-HUB proposal 2 hash 'sha1'
    set vpn ipsec ipsec-interfaces 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 bind tunnel 'tun200'
    set vpn ipsec profile NHRPVPN esp-group 'ESP-HUB'
    set vpn ipsec profile NHRPVPN ike-group 'IKE-HUB'
    
- Spoke-3:

.. code-block:: none
   
    set interfaces tunnel tun100 address '172.16.253.133/29'
    set interfaces tunnel tun100 encapsulation 'gre'
    set interfaces tunnel tun100 multicast 'enable'
    set interfaces tunnel tun100 parameters ip key '1'
    set interfaces tunnel tun100 source-address '0.0.0.0'
    set interfaces tunnel tun200 address '172.16.254.133/29'
    set interfaces tunnel tun200 encapsulation 'gre'
    set interfaces tunnel tun200 multicast 'enable'
    set interfaces tunnel tun200 parameters ip key '2'
    set interfaces tunnel tun200 source-address '0.0.0.0'
    
    set protocols nhrp tunnel tun100 cisco-authentication 'secret'
    set protocols nhrp tunnel tun100 holding-time '30'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 nbma-address '10.11.0.1'
    set protocols nhrp tunnel tun100 map 172.16.253.134/29 register
    set protocols nhrp tunnel tun100 multicast 'nhs'
    set protocols nhrp tunnel tun100 redirect
    set protocols nhrp tunnel tun100 shortcut
    set protocols nhrp tunnel tun200 cisco-authentication 'secret'
    set protocols nhrp tunnel tun200 holding-time '30'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 nbma-address '10.21.0.1'
    set protocols nhrp tunnel tun200 map 172.16.254.134/29 register
    set protocols nhrp tunnel tun200 multicast 'nhs'
    set protocols nhrp tunnel tun200 redirect
    set protocols nhrp tunnel tun200 shortcut
    
    set vpn ipsec esp-group ESP-HUB compression 'disable'
    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 esp-group ESP-HUB proposal 2 encryption '3des'
    set vpn ipsec esp-group ESP-HUB proposal 2 hash 'md5'
    set vpn ipsec ike-group IKE-HUB close-action 'none'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection action 'restart'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection interval '3'
    set vpn ipsec ike-group IKE-HUB dead-peer-detection timeout '30'
    set vpn ipsec ike-group IKE-HUB ikev2-reauth 'no'
    set vpn ipsec ike-group IKE-HUB key-exchange 'ikev2'
    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 ike-group IKE-HUB proposal 2 dh-group '2'
    set vpn ipsec ike-group IKE-HUB proposal 2 encryption 'aes128'
    set vpn ipsec ike-group IKE-HUB proposal 2 hash 'sha1'
    set vpn ipsec ipsec-interfaces 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 bind tunnel 'tun200'
    set vpn ipsec profile NHRPVPN esp-group 'ESP-HUB'
    set vpn ipsec profile NHRPVPN ike-group 'IKE-HUB'
    


Step-4: Enabling eBGP as a Dynamic Routing Protocol between Hubs and Spokes
===========================================================================

For the simplified and better network management we're using eBGP for routing 
information exchange between devices. As we're using Active-Standby mode in 
this example, Hub-2 is configured with AS-prepand as an export route-policy 
and VRRP transition scripts are used for switching mastership based on the 
current link/device state. Also, we use multihop BFD for faster eBGP failure 
detection.

Hub-1 and Hub-2 VRRP transition scripts:
________________________________________

* /config/scripts/vrrp-master.sh

.. code-block:: none
    
    #!/bin/vbash

    if [ $(id -gn) != vyattacfg ]; then
        exec sg vyattacfg "$0 $*"
    fi
    
    source /opt/vyatta/etc/functions/script-template
    
    configure
    delete protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map export AS65000-PREP
    commit
    
    exit


* /config/scripts/vrrp-fail.sh

.. code-block:: none
    
    #!/bin/vbash

    if [ $(id -gn) != vyattacfg ]; then
        exec sg vyattacfg "$0 $*"
    fi
    
    source /opt/vyatta/etc/functions/script-template
    
    configure
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map export AS65000-PREP
    commit
    
    exit


**Note**: some parts of the script might be dependent on your network topology 
and connectivity. Be careful before using it on your own devices.


Hub devices configuration:
__________________________

- Hub-1:

.. code-block:: none
   
    set high-availability vrrp group HQ transition-script backup '/config/scripts/vrrp-fail.sh'
    set high-availability vrrp group HQ transition-script fault '/config/scripts/vrrp-fail.sh'
    set high-availability vrrp group HQ transition-script master '/config/scripts/vrrp-master.sh'
    set high-availability vrrp group HQ transition-script stop '/config/scripts/vrrp-fail.sh'
    
    set policy route-map AS65000-PREP rule 1 action 'permit'
    set policy route-map AS65000-PREP rule 1 set as-path-prepend '65000 65000 65000'
    
    set protocols bfd peer 172.16.253.131 interval multiplier '3'
    set protocols bfd peer 172.16.253.131 interval receive '300'
    set protocols bfd peer 172.16.253.131 interval transmit '300'
    set protocols bfd peer 172.16.253.131 multihop
    set protocols bfd peer 172.16.253.131 source address '172.16.253.134'
    set protocols bfd peer 172.16.253.132 interval multiplier '3'
    set protocols bfd peer 172.16.253.132 interval receive '300'
    set protocols bfd peer 172.16.253.132 interval transmit '300'
    set protocols bfd peer 172.16.253.132 multihop
    set protocols bfd peer 172.16.253.132 source address '172.16.253.134'
    set protocols bfd peer 172.16.253.133 interval multiplier '3'
    set protocols bfd peer 172.16.253.133 interval receive '300'
    set protocols bfd peer 172.16.253.133 interval transmit '300'
    set protocols bfd peer 172.16.253.133 multihop
    set protocols bfd peer 172.16.253.133 source address '172.16.253.134'
    
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.253.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.253.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.253.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 parameters network-import-check
    set protocols bgp 65000 peer-group DMVPN bfd

- Hub-2:

.. code-block:: none
   
    set high-availability vrrp group HQ transition-script backup '/config/scripts/vrrp-fail.sh'
    set high-availability vrrp group HQ transition-script fault '/config/scripts/vrrp-fail.sh'
    set high-availability vrrp group HQ transition-script master '/config/scripts/vrrp-master.sh'
    set high-availability vrrp group HQ transition-script stop '/config/scripts/vrrp-fail.sh'
    
    set policy route-map AS65000-PREP rule 1 action 'permit'
    set policy route-map AS65000-PREP rule 1 set as-path-prepend '65000 65000 65000'
    
    set protocols bfd peer 172.16.254.131 interval multiplier '3'
    set protocols bfd peer 172.16.254.131 interval receive '300'
    set protocols bfd peer 172.16.254.131 interval transmit '300'
    set protocols bfd peer 172.16.254.131 multihop
    set protocols bfd peer 172.16.254.131 source address '172.16.254.134'
    set protocols bfd peer 172.16.254.132 interval multiplier '3'
    set protocols bfd peer 172.16.254.132 interval receive '300'
    set protocols bfd peer 172.16.254.132 interval transmit '300'
    set protocols bfd peer 172.16.254.132 multihop
    set protocols bfd peer 172.16.254.132 source address '172.16.254.134'
    set protocols bfd peer 172.16.254.133 interval multiplier '3'
    set protocols bfd peer 172.16.254.133 interval receive '300'
    set protocols bfd peer 172.16.254.133 interval transmit '300'
    set protocols bfd peer 172.16.254.133 multihop
    set protocols bfd peer 172.16.254.133 source address '172.16.254.134'
    
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.254.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.254.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.254.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 parameters network-import-check
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map export 'AS65000-PREP'
    set protocols bgp 65000 peer-group DMVPN bfd
    
Spoke devices configuration:
____________________________

- Spoke-1:

.. code-block:: none
   
    set protocols bfd peer 172.16.253.134 interval multiplier '3'
    set protocols bfd peer 172.16.253.134 interval receive '300'
    set protocols bfd peer 172.16.253.134 interval transmit '300'
    set protocols bfd peer 172.16.253.134 multihop
    set protocols bfd peer 172.16.253.134 source address '172.16.253.131'
    set protocols bfd peer 172.16.254.134 interval multiplier '3'
    set protocols bfd peer 172.16.254.134 interval receive '300'
    set protocols bfd peer 172.16.254.134 interval transmit '300'
    set protocols bfd peer 172.16.254.134 multihop
    set protocols bfd peer 172.16.254.134 source address '172.16.254.131'
    
    set protocols bgp 65001 address-family ipv4-unicast network 192.168.1.0/24
    set protocols bgp 65001 neighbor 172.16.253.134 address-family ipv4-unicast
    set protocols bgp 65001 neighbor 172.16.253.134 bfd
    set protocols bgp 65001 neighbor 172.16.253.134 remote-as '65000'
    set protocols bgp 65001 neighbor 172.16.254.134 address-family ipv4-unicast
    set protocols bgp 65001 neighbor 172.16.254.134 bfd
    set protocols bgp 65001 neighbor 172.16.254.134 remote-as '65000'
    set protocols bgp 65001 parameters log-neighbor-changes
    
- Spoke-2:

.. code-block:: none
   
    set protocols bfd peer 172.16.253.134 interval multiplier '3'
    set protocols bfd peer 172.16.253.134 interval receive '300'
    set protocols bfd peer 172.16.253.134 interval transmit '300'
    set protocols bfd peer 172.16.253.134 multihop
    set protocols bfd peer 172.16.253.134 source address '172.16.253.132'
    set protocols bfd peer 172.16.254.134 interval multiplier '3'
    set protocols bfd peer 172.16.254.134 interval receive '300'
    set protocols bfd peer 172.16.254.134 interval transmit '300'
    set protocols bfd peer 172.16.254.134 multihop
    set protocols bfd peer 172.16.254.134 source address '172.16.254.132'
    
    set protocols bgp 65002 address-family ipv4-unicast network 192.168.2.0/24
    set protocols bgp 65002 neighbor 172.16.253.134 address-family ipv4-unicast
    set protocols bgp 65002 neighbor 172.16.253.134 bfd
    set protocols bgp 65002 neighbor 172.16.253.134 remote-as '65000'
    set protocols bgp 65002 neighbor 172.16.254.134 address-family ipv4-unicast
    set protocols bgp 65002 neighbor 172.16.254.134 bfd
    set protocols bgp 65002 neighbor 172.16.254.134 remote-as '65000'
    set protocols bgp 65002 parameters log-neighbor-changes
    
- Spoke-3:

.. code-block:: none
   
    set protocols bfd peer 172.16.253.134 interval multiplier '3'
    set protocols bfd peer 172.16.253.134 interval receive '300'
    set protocols bfd peer 172.16.253.134 interval transmit '300'
    set protocols bfd peer 172.16.253.134 multihop
    set protocols bfd peer 172.16.253.134 source address '172.16.253.133'
    set protocols bfd peer 172.16.254.134 interval multiplier '3'
    set protocols bfd peer 172.16.254.134 interval receive '300'
    set protocols bfd peer 172.16.254.134 interval transmit '300'
    set protocols bfd peer 172.16.254.134 multihop
    set protocols bfd peer 172.16.254.134 source address '172.16.254.133'
    
    set protocols bgp 65003 address-family ipv4-unicast network 192.168.3.0/24
    set protocols bgp 65003 neighbor 172.16.253.134 address-family ipv4-unicast
    set protocols bgp 65003 neighbor 172.16.253.134 bfd
    set protocols bgp 65003 neighbor 172.16.253.134 remote-as '65000'
    set protocols bgp 65003 neighbor 172.16.254.134 address-family ipv4-unicast
    set protocols bgp 65003 neighbor 172.16.254.134 bfd
    set protocols bgp 65003 neighbor 172.16.254.134 remote-as '65000'
    set protocols bgp 65003 parameters log-neighbor-changes
    
**Note**: In case if you're using VyOS version that has a VRRP transition 
scripts issues after a device reboot, as a temporary solution you may add
postconfig-bootup script that reloads **keepalived** process additionally after 
the device booted.

- Hub devices /config/scripts/vyos-postconfig-bootup.script:

.. code-block:: none
   
    #!/bin/sh
    # This script is executed at boot time after VyOS configuration is fully applied.
    # Any modifications required to work around unfixed bugs
    # or use services not available through the VyOS CLI system can be placed here.
    
    echo "Reloading VRRP process"
    sudo systemctl restart keepalived.service
    echo "VRRP process reload completed"



Step-5: Verification
====================

Now, it's time to check that all protocols are working as expected and mastership 
during the failover switches correctly between Hub devices.

- Checking VRRP state between Hub-1 and Hub-2:

.. code-block:: none
   
    vyos@Hub-1:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  MASTER          200  14s
    
    vyos@Hub-2:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  BACKUP          100  29s

- Checking NHRP and eBGP sessions between Hub and Spoke devices:

.. code-block:: none
   
    vyos@Hub-1:~$ show nhrp tunnel
    Status: ok
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.135/32
    Alias-Address: 172.16.253.134
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.134/32
    Flags: up
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.253.131/32
    NBMA-Address: 10.11.1.11
    Flags: up
    Expires-In: 0:23
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.253.133/32
    NBMA-Address: 10.31.1.11
    Flags: up
    Expires-In: 0:22
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.253.132/32
    NBMA-Address: 10.21.1.11
    Flags: up
    Expires-In: 0:21
    
    vyos@Hub-1:~$ show bgp summary
    
    IPv4 Unicast Summary:
    BGP router identifier 192.168.0.1, local AS number 65000 vrf-id 0
    BGP table version 20
    RIB entries 7, using 1344 bytes of memory
    Peers 3, using 64 KiB of memory
    Peer groups 1, using 64 bytes of memory
    
    Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
    172.16.253.131  4      65001     26519     26526        0    0    0 00:43:38            1        4
    172.16.253.132  4      65002     26545     26540        0    0    0 00:46:36            1        4
    172.16.253.133  4      65003     26528     26520        0    0    0 00:41:59            1        4
    
    Total number of neighbors 3
    
    
    vyos@Hub-2:~$ show nhrp tunnel
    Status: ok
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.254.135/32
    Alias-Address: 172.16.254.134
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.254.134/32
    Flags: up
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.254.132/32
    NBMA-Address: 10.21.1.11
    Flags: up
    Expires-In: 0:28
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.254.131/32
    NBMA-Address: 10.11.1.11
    Flags: up
    Expires-In: 0:21
    
    Interface: tun100
    Type: dynamic
    Protocol-Address: 172.16.254.133/32
    NBMA-Address: 10.31.1.11
    Flags: up
    Expires-In: 0:20
    
    vyos@Hub-2:~$ show bgp summary
    
    IPv4 Unicast Summary:
    BGP router identifier 192.168.0.2, local AS number 65000 vrf-id 0
    BGP table version 14
    RIB entries 7, using 1344 bytes of memory
    Peers 3, using 64 KiB of memory
    Peer groups 1, using 64 bytes of memory
    
    Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
    172.16.254.131  4      65001     26516     26516        0    0    0 00:43:03            1        4
    172.16.254.132  4      65002     26563     26562        0    0    0 00:48:27            1        4
    172.16.254.133  4      65003     26518     26516        0    0    0 00:42:20            1        4
    
    Total number of neighbors 3
    
- Checking BFD sessions between Hub and Spoke devices:

.. code-block:: none
   
    vyos@Hub-1:~$ show protocols bfd peers
    Session count: 6
    SessionId  LocalAddress                             PeerAddress                             Status
    =========  ============                             ===========                             ======
    3600626867 172.16.253.134                           172.16.253.133                          up
    1123939978 172.16.253.134                           172.16.253.131                          up
    374394280  172.16.253.134                           172.16.253.132                          up
    1786735466 172.16.253.134                           172.16.253.132                          up
    1440522544 172.16.253.134                           172.16.253.131                          up
    1106910911 172.16.253.134                           172.16.253.133                          up
    
    
    vyos@Hub-2:~$ show protocols bfd peers
    Session count: 6
    SessionId  LocalAddress                             PeerAddress                             Status
    =========  ============                             ===========                             ======
    2442966178 172.16.254.134                           172.16.254.133                          up
    393258775  172.16.254.134                           172.16.254.131                          up
    2990308682 172.16.254.134                           172.16.254.133                          up
    2267910949 172.16.254.134                           172.16.254.132                          up
    3542474595 172.16.254.134                           172.16.254.131                          up
    4239538185 172.16.254.134                           172.16.254.132                          up

- Checking routing information and connectivity between Hub and Spoke devices:

.. code-block:: none
   
    vyos@Hub-1:~$ show ip bgp
    BGP table version is 20, local router ID is 192.168.0.1, vrf id 0
    Default local pref 100, local AS 65000
    Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
                   i internal, r RIB-failure, S Stale, R Removed
    Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
    Origin codes:  i - IGP, e - EGP, ? - incomplete
    
       Network          Next Hop            Metric LocPrf Weight Path
    *> 192.168.0.0/24   0.0.0.0                  0         32768 i
    *> 192.168.1.0/24   172.16.253.131           0             0 65001 i
    *> 192.168.2.0/24   172.16.253.132           0             0 65002 i
    *> 192.168.3.0/24   172.16.253.133           0             0 65003 i
    
    Displayed  4 routes and 4 total paths


    vyos@Hub-2:~$ show ip bgp
    BGP table version is 14, local router ID is 192.168.0.2, vrf id 0
    Default local pref 100, local AS 65000
    Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
                   i internal, r RIB-failure, S Stale, R Removed
    Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
    Origin codes:  i - IGP, e - EGP, ? - incomplete
    
       Network          Next Hop            Metric LocPrf Weight Path
    *> 192.168.0.0/24   0.0.0.0                  0         32768 i
    *> 192.168.1.0/24   172.16.254.131           0             0 65001 i
    *> 192.168.2.0/24   172.16.254.132           0             0 65002 i
    *> 192.168.3.0/24   172.16.254.133           0             0 65003 i
    
    Displayed  4 routes and 4 total paths


    vyos@Spoke-1:~$ show ip bgp
    BGP table version is 19, local router ID is 192.168.1.1, vrf id 0
    Default local pref 100, local AS 65001
    Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
                   i internal, r RIB-failure, S Stale, R Removed
    Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
    Origin codes:  i - IGP, e - EGP, ? - incomplete
    
       Network          Next Hop            Metric LocPrf Weight Path
    *  192.168.0.0/24   172.16.254.134           0             0 65000 65000 65000 65000 i
    *>                  172.16.253.134           0             0 65000 i
    *> 192.168.1.0/24   0.0.0.0                  0         32768 i
    *  192.168.2.0/24   172.16.254.132                         0 65000 65000 65000 65000 65002 i
    *>                  172.16.253.132                         0 65000 65002 i
    *  192.168.3.0/24   172.16.254.133                         0 65000 65000 65000 65000 65003 i
    *>                  172.16.253.133                         0 65000 65003 i
    
    Displayed  4 routes and 7 total paths

As you can see, Hub-2 announces routes with longer(prepended) AS path as 
we've configured it previously, those, traffic towards HQ subnet will be 
forwarded over Hub-1 which is operating as an Active VRRP router. Let's 
check connectivity and the path from Spoke-1 to the HQ local network:

.. code-block:: none
   
    vyos@Spoke-1:~$ ping 192.168.0.10 count 5 interface 192.168.1.1
    PING 192.168.0.10 (192.168.0.10) from 192.168.1.1 : 56(84) bytes of data.
    64 bytes from 192.168.0.10: icmp_seq=1 ttl=63 time=3.50 ms
    64 bytes from 192.168.0.10: icmp_seq=2 ttl=63 time=2.45 ms
    64 bytes from 192.168.0.10: icmp_seq=3 ttl=63 time=2.34 ms
    64 bytes from 192.168.0.10: icmp_seq=4 ttl=63 time=2.20 ms
    64 bytes from 192.168.0.10: icmp_seq=5 ttl=63 time=2.44 ms
    
    --- 192.168.0.10 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 11ms
    rtt min/avg/max/mdev = 2.195/2.583/3.496/0.465 ms
    
    vyos@Spoke-1:~$ traceroute 192.168.0.10
    traceroute to 192.168.0.10 (192.168.0.10), 30 hops max, 60 byte packets
     1  172.16.253.134 (172.16.253.134)  0.913 ms  0.884 ms  0.819 ms
     2  192.168.0.10 (192.168.0.10)  1.352 ms  1.446 ms  1.391 ms

From the output, we can confirm successful connectivity between Spoke-1 and HQ 
local networks. From the traceroute we see that the traffic pass through the 
Hub-1.

Now, let's check traffic between Spoke sites. Based on our configuration, Spoke 
sites are using shortcut for direct reachability between each other. First, let's 
check NHRP tunnels before passing the traffic between Spoke-1 and Spoke-2:

.. code-block:: none
   
    vyos@Spoke-1:~$ show nhrp tunnel
    Status: ok
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.135/32
    Alias-Address: 172.16.254.131
    Flags: up
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.131/32
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.135/32
    Alias-Address: 172.16.253.131
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.131/32
    Flags: up
    
    Interface: tun200
    Type: static
    Protocol-Address: 172.16.254.134/29
    NBMA-Address: 10.21.0.1
    Flags: used up
    
    Interface: tun100
    Type: static
    Protocol-Address: 172.16.253.134/29
    NBMA-Address: 10.11.0.1
    Flags: used up

    vyos@Spoke-2:~$ show nhrp tunnel
    Status: ok
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.135/32
    Alias-Address: 172.16.253.132
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.132/32
    Flags: up
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.135/32
    Alias-Address: 172.16.254.132
    Flags: up
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.132/32
    Flags: up
    
    Interface: tun100
    Type: static
    Protocol-Address: 172.16.253.134/29
    NBMA-Address: 10.11.0.1
    Flags: used up
    
    Interface: tun200
    Type: static
    Protocol-Address: 172.16.254.134/29
    NBMA-Address: 10.21.0.1


After passing traffic we could see that there is additional shortcut tunnel 
created between Spoke-1 and Spoke-2 for the direct communication:

.. code-block:: none
   
    vyos@Spoke-1:~$ ping 192.168.2.1 count 5 interface 192.168.1.1
    PING 192.168.2.1 (192.168.2.1) from 192.168.1.1 : 56(84) bytes of data.
    64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=1.03 ms
    64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=0.820 ms
    64 bytes from 192.168.2.1: icmp_seq=3 ttl=64 time=1.13 ms
    64 bytes from 192.168.2.1: icmp_seq=4 ttl=63 time=1.41 ms
    64 bytes from 192.168.2.1: icmp_seq=5 ttl=64 time=0.988 ms
    
    --- 192.168.2.1 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 10ms
    rtt min/avg/max/mdev = 0.820/1.075/1.412/0.197 ms
    
    vyos@Spoke-1:~$ traceroute 192.168.2.1
    traceroute to 192.168.2.1 (192.168.2.1), 30 hops max, 60 byte packets
     1  192.168.2.1 (192.168.2.1)  1.172 ms  1.109 ms  1.151 ms

    vyos@Spoke-1:~$ show nhrp tunnel
    Status: ok
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.135/32
    Alias-Address: 172.16.254.131
    Flags: up
    
    Interface: tun200
    Type: local
    Protocol-Address: 172.16.254.131/32
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.135/32
    Alias-Address: 172.16.253.131
    Flags: up
    
    Interface: tun100
    Type: local
    Protocol-Address: 172.16.253.131/32
    Flags: up
    
    Interface: tun200
    Type: static
    Protocol-Address: 172.16.254.134/29
    NBMA-Address: 10.21.0.1
    Flags: used up
    
    ____________________________________
    Interface: tun100
    Type: cached
    Protocol-Address: 172.16.253.132/32
    NBMA-Address: 10.21.1.11
    Flags: used up
    Expires-In: 0:24
    ____________________________________
    
    Interface: tun100
    Type: static
    Protocol-Address: 172.16.253.134/29
    NBMA-Address: 10.11.0.1
    Flags: used up

The same applies to the rest of the devices and works with the same logic. 
As we've already confirmed successfull connectivity between Hub and Spoke 
devices, let's check failover process.

- Failover on the health-check failure on Hub-1:
  
.. code-block:: none
   
    # disabling interface towards Hub-1 on ISP router
    vyos@ISP1:~$ configure
    [edit]
    vyos@ISP1# set interfaces ethernet eth0 disable
    [edit]
    vyos@ISP1# commit
    [edit]
    vyos@ISP1#


    # checking VRRP state and eBGP configuration on Hub-1:
    vyos@Hub-1:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  FAULT           200  1m15s
    
    vyos@Hub-1:~$ show configuration commands | match bgp
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.253.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.253.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.253.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map export 'AS65000-PREP'
    set protocols bgp 65000 peer-group DMVPN bfd


    # consecutive pings check from Spoke-1 to the HQ local network during the failure
    --- 192.168.0.10 ping statistics ---
    223 packets transmitted, 219 received, 1.79372% packet loss, time 679ms
    rtt min/avg/max/mdev = 0.918/2.191/2.957/0.364 ms
    vyos@Spoke-1:~$


    # consecutive pings check from Spoke-3 to the Spoke-2 local network during the failure
    --- 192.168.2.1 ping statistics ---
    265 packets transmitted, 265 received, 0% packet loss, time 690ms
    rtt min/avg/max/mdev = 0.663/1.128/2.272/0.285 ms
    vyos@Spoke-3:~$

**Note**: After bringing ISP interface towards Hub-1 back to UP state, 
VRRP state will remain unchanged due to "no-preempt" option enabled 
under the VRRP configuration on the Hub-1 and Hub-2 and will be changed 
only during link/device failure on Hub-2.
    
- Failover during Hub-2 device failure:

.. code-block:: none
   
    # Checking VRRP state and eBGP configuration on Hub-2 before reboot
    vyos@Hub-2:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  MASTER          100  20m22s

    vyos@Hub-2:~$ show configuration commands | match bgp
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.254.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.254.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.254.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map
    set protocols bgp 65000 peer-group DMVPN bfd


    # Rebooting Hub-2
    vyos@Hub-2:~$ reboot
    Are you sure you want to reboot this system? [y/N]  y

    
    # Checking VRRP state and eBGP configuration on Hub-1
    vyos@Hub-1:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  MASTER          200  1m57s
    
    vyos@Hub-1:~$ show configuration commands | match bgp
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.253.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.253.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.253.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.253.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map
    set protocols bgp 65000 peer-group DMVPN bfd
    
    
    # Checking VRRP state and eBGP configuration on Hub-2 after reboot completed
    vyos@Hub-2:~$ show vrrp
    Name    Interface      VRID  State      Priority  Last Transition
    ------  -----------  ------  -------  ----------  -----------------
    HQ      eth1v1            1  BACKUP          100  1m46s
    
    vyos@Hub-2:~$ show configuration commands | match bgp
    set protocols bgp 65000 address-family ipv4-unicast network 192.168.0.0/24
    set protocols bgp 65000 neighbor 172.16.254.131 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.131 remote-as '65001'
    set protocols bgp 65000 neighbor 172.16.254.132 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.132 remote-as '65002'
    set protocols bgp 65000 neighbor 172.16.254.133 peer-group 'DMVPN'
    set protocols bgp 65000 neighbor 172.16.254.133 remote-as '65003'
    set protocols bgp 65000 parameters log-neighbor-changes
    set protocols bgp 65000 peer-group DMVPN address-family ipv4-unicast route-map export 'AS65000-PREP'
    set protocols bgp 65000 peer-group DMVPN bfd


    # consecutive pings check from Spoke-1 to the HQ local network during the failure
    --- 192.168.0.10 ping statistics ---
    1182 packets transmitted, 1182 received, 0% packet loss, time 1921ms
    rtt min/avg/max/mdev = 0.890/1.692/3.305/0.503 ms
    vyos@Spoke-1:~$


    # consecutive pings check from Spoke-3 to the Spoke-2 local network during the failure
    --- 192.168.2.1 ping statistics ---
    1186 packets transmitted, 1186 received, 0% packet loss, time 2100ms
    rtt min/avg/max/mdev = 0.506/1.236/8.497/0.369 ms
    vyos@Spoke-3:~$

From the results, we can see that the switchover performed as expected with 
0 packets loss both from Spoke-1 to HQ and Spoke-3 to Spoke-2 networks.