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
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
|
---
myst:
html_meta:
description: |
BGP is the path-vector exterior gateway protocol used to exchange
routing and reachability information between autonomous systems on
the internet.
keywords: bgp, ebgp, ibgp, asn, route-reflector, confederation, peer-group
---
(bgp)=
# BGP
Border Gateway Protocol (BGP) is the path-vector exterior gateway protocol
used to exchange routing and reachability information between
{abbr}`ASs (Autonomous Systems)` on the Internet. BGP-4, the current
version, is specified in
[RFC 4271](https://datatracker.ietf.org/doc/html/rfc4271). Multiprotocol
extensions to BGP, which allow it to carry routing information for address
families beyond IPv4 unicast, are defined in
[RFC 4760](https://datatracker.ietf.org/doc/html/rfc4760).
## Basic concepts
### Autonomous systems
An {abbr}`AS (Autonomous System)` is a connected group of IP prefixes
managed by one or more network operators under a single, clearly defined
routing policy
([RFC 1930](https://datatracker.ietf.org/doc/html/rfc1930)).
Every AS is identified by an {abbr}`ASN (Autonomous System Number)`. ASNs
were originally two-byte values (1-65535), with the range 64512-65534
reserved for private use
([RFC 6996](https://datatracker.ietf.org/doc/html/rfc6996)) and prohibited
on the global Internet. The two-byte pool has since been exhausted, so
regional Internet registries now allocate four-byte ASNs (1-4,294,967,295) by
default, as defined in
[RFC 6793](https://datatracker.ietf.org/doc/html/rfc6793).
ASNs are essential elements of BGP. As a path-vector protocol, BGP records
the chain of ASNs a route has crossed in the AS_PATH attribute and uses
that chain both as a metric in best path selection (shorter AS_PATH wins,
other criteria being equal) and as a loop-detection mechanism.
### Address families
Multiprotocol BGP extensions enable BGP to carry routing information for
multiple network-layer protocols. Each address family is identified by an
{abbr}`AFI (Address Family Identifier)`/
{abbr}`SAFI (Subsequent Address Family Identifier)`
pair: the AFI names the network-layer protocol (IPv4, IPv6, etc.), and the
SAFI names the route type (unicast, multicast, MPLS-labeled, VPN, etc.).
VyOS supports IPv4 and IPv6 unicast, multicast, labeled unicast, VPN
(MPLS L3VPN), and flowspec address families, plus the L2VPN-EVPN and
BGP Link-State families. This document covers configuration of the IPv4
and IPv6 unicast address families, which are the most common in
inter-domain routing.
### Route selection
FRR's BGP implementation selects routes by applying the following decision
criteria, in order from top to bottom, until one is applicable.
1. **Weight check:** Prefer the route with the higher local weight.
2. **Local preference check:** Prefer the route with the higher
LOCAL_PREF.
3. **Local route check:** Prefer locally originated routes (statics,
aggregates, redistributed) over received routes.
4. **AS path length check:** Prefer the route with the shortest AS_PATH
length.
5. **Origin check:** Prefer the route with the lowest origin type
(IGP < EGP < Incomplete).
6. **MED check:** When multiple routes are received from the same
neighboring AS, prefer the route with the lowest
{abbr}`MED (Multi-Exit Discriminator)` value.
7. **External check:** Prefer the route received from an external (eBGP)
peer over routes received from other types of peers.
8. **IGP cost check:** Prefer the route with the lower IGP cost to the
next hop.
9. **Multi-path check:** If multi-path routing is enabled, check whether the
routes not yet distinguished in preference may be considered equal. If
`bestpath as-path multipath-relax` is set, all such routes are
considered equal; otherwise, routes received via iBGP with identical
AS_PATHs, or routes received from eBGP neighbors in the same AS, are
considered equal.
10. **Already-selected external check:** When both routes are received
from eBGP peers, prefer the route that was already selected. This
check is skipped if `bestpath compare-routerid` is configured. It can
prevent some cases of route oscillation.
11. **Router ID check:** Prefer the route with the lowest router ID. If
the route has an ORIGINATOR_ID attribute (set during iBGP
reflection), that value is used; otherwise, the router ID of the peer
the route was received from is used.
12. **Cluster list length check:** Prefer the route with the shortest
CLUSTER_LIST length. The cluster list reflects the iBGP reflection
path the route has taken.
13. **Peer address:** Prefer the route received from the peer with the
lowest transport-layer IP address, as a last-resort tie-breaker.
### Capability advertisement
BGP-4 originally had no mechanism for a speaker to advertise which optional
protocol features it supports. Capability advertisement, defined in
[RFC 5492](https://datatracker.ietf.org/doc/html/rfc5492), addresses this
by allowing each BGP speaker to list its supported capabilities in the
OPEN message. Capabilities cover features such as multiprotocol
extensions, route refresh, 4-byte ASN support, graceful restart, and
ADD-PATH.
By default, a BGP implementation brings up a peering with the minimal
capabilities that are common to both sides. For example, if the local
router supports both unicast and multicast and the remote router
supports only unicast, the session is established with unicast
capability only. When the two sides share no common capabilities, one
side sends an Unsupported Capability error and terminates the session.
If a peer is configured exclusively as an IPv4 unicast neighbor and no
other optional features require capability negotiation, VyOS' BGP
implementation does not send any capability advertisements.
## Configuration
### Local BGP router configuration
Configure the local BGP router with its ASN. The BGP process uses the ASN
to determine if a session is internal (iBGP) or external (eBGP).
```{cfgcmd} set protocols bgp system-as \<1-4294967294\>
**Configure the Autonomous System Number (ASN) for the local BGP router.**
This setting is mandatory. ASN 0 and ASN 4294967295 are reserved
([RFC 7607](https://datatracker.ietf.org/doc/html/rfc7607),
[RFC 7300](https://datatracker.ietf.org/doc/html/rfc7300)) and cannot be
configured.
```
Example:
```none
set protocols bgp system-as 64512
```
### Peer configuration
#### Defining peers
```{cfgcmd} set protocols bgp neighbor \<address | interface\> remote-as \<1-4294967294 | auto | external | internal\>
**Configure the ASN of the specified BGP neighbor.**
The neighbor identity can be an IPv4 address, an IPv6 address (including a
link-local address), or an interface name for unnumbered peering.
The ASN can be configured as:
- An explicit number in the range 1 to 4294967294.
- `auto`: automatically detect the neighbor's ASN from the OPEN
message.
- `external`: reject the connection if the peer's ASN matches the
local AS (eBGP session).
- `internal`: reject the connection if the peer's ASN differs from
the local AS (iBGP session).
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 remote-as 64513
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> remote-as internal
**Configure the specified neighbor as an iBGP peer.**
The peer's AS number must match the locally configured `system-as`. If it
does not, the BGP peering session with this neighbor is rejected.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 remote-as internal
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> remote-as external
**Configure the specified neighbor as an eBGP peer.**
The peer's AS number must differ from the locally configured `system-as`.
If it matches, the BGP peering session with this neighbor is rejected.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 remote-as external
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> remote-as auto
**Configure a BGP neighbor whose ASN is learned from the OPEN message
this neighbor sends at session setup.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 remote-as auto
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> port \<1-65535\>
**Configure the TCP destination port used when initiating the BGP session
with the specified peer.**
By default, BGP uses TCP port 179 (IANA-assigned).
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 port 1179
```
```{cfgcmd} set protocols bgp neighbor \<interface\> interface source-interface \<interface\>
**Configure the local source interface used for the unnumbered BGP
session.**
```
```{note}
This command applies only when the neighbor is specified by interface
name (unnumbered peering).
```
Example:
```none
set protocols bgp neighbor eth1 interface source-interface eth1
```
```{cfgcmd} set protocols bgp neighbor \<interface\> interface v6only remote-as \<1-4294967294 | auto | external | internal\>
**Configure an IPv6 link-local-only unnumbered peering on the specified
interface and set the neighbor's ASN.**
With `v6only`, the BGP session is established over the IPv6 link-local
address of the interface without requiring any globally routable
address on either side.
The ASN can be configured as:
- An explicit number in the range 1 to 4294967294.
- `auto`: automatically detect the neighbor's ASN from the OPEN
message.
- `external`: Any non-local ASN, treated as eBGP.
- `internal`: The same ASN as the local router, treated as iBGP.
```
Example:
```none
set protocols bgp neighbor eth1 interface v6only remote-as external
```
```{cfgcmd} set protocols bgp neighbor \<interface\> interface v6only peer-group \<name\>
**Assign an IPv6-link-local-only unnumbered peering on the specified
interface to a peer group.**
The unnumbered peering inherits all parameters from the peer group.
```
```{note}
The peer group must already be configured.
```
Example:
```none
set protocols bgp neighbor eth1 interface v6only peer-group FABRIC
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> local-role \<customer | peer | provider | rs-client | rs-server\> [strict]
**Configure the local BGP role for the session
([RFC 9234](https://datatracker.ietf.org/doc/html/rfc9234)).**
Each side advertises its role via the BGP Role capability, and the
following two roles form a valid pairing:
- Provider <-> Customer
- RS-Server <-> RS-Client
- Peer <-> Peer
If the roles do not pair correctly, the session is rejected with a Role
Mismatch notification.
When `strict` is set, the session requires the neighbor to advertise its
role. If the neighbor does not include the BGP Role capability, the
session is rejected. Enable this option when you want to be sure the
other side is also role-configured.
Once the local role is set, the BGP daemon automatically applies the
{abbr}`OTC (Only-to-Customer)` attribute to detect and prevent route
leaks:
- Routes sent to a Customer, RS-Client, or Peer are tagged with OTC.
- Routes already carrying OTC are not sent back up to a Provider,
RS-Server, or Peer.
- Between two peers, a received route with OTC is accepted only if the
OTC value equals the peer's ASN.
- Routes received from a Customer or RS-Client that already carry OTC are
treated as route leaks and rejected.
No extra policy configuration is needed; the rules apply automatically.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 local-role customer strict
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> shutdown
**Administratively disable the BGP session with the specified peer.**
To re-enable the session, use the `delete` form of this command.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 shutdown
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> description \<text\>
**Configure a free-form description for the specified peer.**
The description may be up to 255 characters.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 description 'Upstream provider'
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> update-source \<address | interface\>
**Configure the source IP address used by the local BGP speaker when
opening the TCP connection to the specified neighbor.**
The source IP address can be specified either as an IP address or as an
interface name.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 update-source 192.0.2.1
```
#### Capability negotiation
```{cfgcmd} set protocols bgp neighbor \<address | interface\> capability dynamic
**Enable Dynamic Capability negotiation with the specified peer.**
This enables updating active capabilities during an established BGP
session without resetting the session.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 capability dynamic
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> capability extended-nexthop
**Enable the Extended Next Hop capability
([RFC 8950](https://datatracker.ietf.org/doc/html/rfc8950)) negotiation
with the specified peer.**
When the BGP session runs over an IPv6 link-local address, this capability
is enabled automatically. When the session runs over an IPv6 global
address, enabling this capability allows BGP to install IPv4 routes with
IPv6 next hops, which is useful when no IPv4 addresses are configured on
the transit interfaces.
```
Example:
```none
set protocols bgp neighbor 2001:db8::2 capability extended-nexthop
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> capability software-version
**Configure BGP to advertise the Software Version capability to the
specified peer.**
This causes the local router to include the name and version of the
software that implements BGP in the OPEN message. It is sent for
purely informational purposes and does not affect BGP behavior.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 capability software-version
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> disable-capability-negotiation
**Suppress sending capability advertisements as OPEN message optional
parameters to the specified peer.**
The session is established using only the basic BGP-4 feature set, as if
capabilities had never been introduced.
```
```{note}
To use the locally configured capabilities regardless of what the peer
advertises, use `override-capability` instead.
```
```{note}
Suppressing capability negotiation disables every BGP feature that
depends on capability exchange, including BGP unnumbered, hostname
support, 4-byte ASNs, ADD-PATH, Route Refresh, ORF, Dynamic Capabilities,
and Graceful Restart. Use this option only when interoperating with a
peer that cannot accept capabilities.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 disable-capability-negotiation
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> override-capability
**Configure the session with the specified peer to use the locally
configured capabilities, ignoring capabilities advertised by the peer.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 override-capability
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> strict-capability-match
**Configure the session with the specified peer to require an exact
match between the local and remote capability sets.**
If the two sets differ, the router sends an Unsupported Capability
notification and resets the connection.
If the peer does not implement capability advertisement at all, use
`disable-capability-negotiation` to suppress local advertisement.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 strict-capability-match
```
#### Peer parameters
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> allowas-in number \<1-10\>
**Configure the session with the specified peer to accept incoming routes
whose AS_PATH contains the local AS, up to the given number of
occurrences.**
This is useful when the same ASN is reused across multiple sites that
cannot be connected directly. The `number` parameter (1-10) sets the
maximum allowed occurrences of the local AS in the AS_PATH.
```
```{note}
This option applies only to eBGP peers and cannot be applied to peer
groups.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast allowas-in number 2
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> as-override
**Configure the session with the specified peer to replace the peer's
ASN in the AS_PATH of advertised routes with the local ASN.**
This is typically used on a {abbr}`PE (Provider Edge)` router to replace
the incoming customer ASN in advertisements to a connected
{abbr}`CE (Customer Edge)`, so customers can reuse the same ASN across
all their sites.
```
```{note}
This option applies only to eBGP peers.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast as-override
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> attribute-unchanged \<as-path | med | next-hop\>
**Configure BGP to advertise the specified path attribute (`as-path`,
`med`, or `next-hop`) to the peer or peer group unchanged.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast attribute-unchanged next-hop
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> maximum-prefix \<1-4294967295\>
**Configure the maximum number of prefixes that the local BGP speaker
will accept from the specified peer.**
If the number of received prefixes exceeds this limit, the BGP session is
torn down.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast maximum-prefix 1000
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> nexthop-self
**Configure the local BGP speaker to advertise itself as the NEXT_HOP
for all routes advertised to the specified peer.**
By default, the local speaker rewrites NEXT_HOP to its own IP address
only when advertising to an eBGP peer and preserves the received NEXT_HOP
when advertising to an iBGP peer. This option overrides the iBGP default.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast nexthop-self
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> nexthop-self force
**Force the local route reflector to set itself as the NEXT_HOP on
routes reflected to its route-reflector clients.**
By default, a route reflector preserves the NEXT_HOP of reflected
routes. This option overrides that behavior for the specified peer,
which must be configured as a route-reflector client for the option to
take effect.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast nexthop-self force
```
<!--
`nexthop-local unchanged` does not work as expected on the live VyOS
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family ipv6-unicast nexthop-local unchanged
-->
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> remove-private-as
**Configure the local BGP speaker to strip private ASNs from the AS_PATH
of routes advertised to the specified eBGP peer.**
Private ASNs are removed only if the AS_PATH consists entirely of
private ASNs. If any public ASN is present in the path, no private ASN
is removed.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast remove-private-as
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> remove-private-as all
**Configure the local BGP speaker to strip all private ASNs from the
AS_PATH of routes advertised to the specified eBGP peer.**
Unlike `remove-private-as` without `all`, this option removes private
ASNs unconditionally — even when public ASNs are also present in the
path.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast remove-private-as all
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> soft-reconfiguration inbound
**Enable inbound soft reconfiguration for the specified peer and address
family.**
When enabled, the router stores incoming updates from the peer unmodified
before any inbound policy is applied. If the inbound policy is changed,
the stored updates are reprocessed locally to produce a new inbound
state, so the session does not need to be cleared to apply policy
changes.
```
```{note}
Storing updates requires memory, and enabling inbound soft
reconfiguration for multiple neighbors can significantly increase memory
usage.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast soft-reconfiguration inbound
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> weight \<1-65535\>
**Configure the default weight applied to routes received from the
specified peer.**
Weight is a purely local attribute. It is never carried in BGP messages and is not
advertised to other peers. Among the best path decision criteria, it is
considered before everything else, and the highest weight wins.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast weight 100
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> advertisement-interval \<0-600\>
**Configure the minimum interval, in seconds, between successive route
advertisements sent to the specified peer for the same destination.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 advertisement-interval 5
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> disable-connected-check
**Allow eBGP sessions to establish regardless of the number of hops
between peers.**
By default, eBGP packets are sent with a TTL of 1, which precludes
sourcing from a non-connected address. This
option bypasses the check.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 disable-connected-check
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> disable-send-community \<extended | standard\>
**Disable sending the specified community attributes to the peer.**
By default, both standard and extended community attributes are sent.
```
Example:
```none
set protocols bgp neighbor 192.0.2.1 address-family ipv4-unicast disable-send-community standard
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> ebgp-multihop \<1-255\>
**Allow an eBGP session with a peer that is not directly connected by
raising the TTL of outbound BGP packets to the specified value.**
By default, eBGP packets are sent with TTL 1, so a peer more than one hop
away is unreachable unless this option is set. Accepted values are
1-255, where 1 is equivalent to the default (single-hop) behavior.
```
```{note}
This command is mutually exclusive with `ttl-security hops`.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 ebgp-multihop 5
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> local-as \<1-4294967294\> [no-prepend [replace-as]]
**Configure an alternate local ASN for the BGP session with the specified
peer. This command applies only to eBGP peers.**
Without modifiers, the `local-as` is prepended to the received AS_PATH
when receiving updates from the peer, and to the outgoing AS_PATH (on
top of the router's real ASN) when sending routes to the peer.
With `no-prepend`, the `local-as` is not prepended to the AS_PATH of
incoming updates from the peer.
With `replace-as`, only the `local-as` is prepended to outgoing updates
to the peer; the router's real ASN is omitted. The `replace-as` modifier
requires `no-prepend` and cannot be used on its own.
```
```{note}
This command applies only to eBGP peers.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 local-as 64600 no-prepend replace-as
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> passive
**Configure the local BGP speaker to only accept inbound TCP connections
from the specified peer and never initiate an outbound connection.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 passive
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> password \<text\>
**Configure a TCP MD5 authentication password for the session with the
specified peer.**
Both sides of the session must be configured with the same password for
the connection to be established.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 password mysharedsecret
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> ttl-security hops \<1-254\>
**Enable the {abbr}`GTSM (Generalized TTL Security Mechanism)` on the
session with the specified peer, as defined in
[RFC 5082](https://datatracker.ietf.org/doc/html/rfc5082).**
When enabled, outbound BGP packets are sent with TTL 255, and inbound
packets are accepted only from peers within the configured number of
hops.
```
```{note}
This command is mutually exclusive with `ebgp-multihop`.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 ttl-security hops 1
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> bfd [profile \<name\>]
**Enable {abbr}`BFD (Bidirectional Forwarding Detection)` on the session
with the specified peer.**
When BFD declares the path to the peer down, the BGP session is reset
immediately rather than waiting for the BGP hold timer to expire.
Optionally, a BFD profile (configured under `set protocols bfd profile`)
can be applied to control detection timers and other parameters. Without
a profile, the default BFD parameters apply.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 bfd profile FAST-LINK
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> bfd check-control-plane-failure
**Configure BGP to set and inspect the BFD C-bit (Control Plane
Independent bit) for the session with the specified peer. This option is
intended for use with BGP Graceful Restart.**
The local router sets the C-bit on outgoing BFD packets and checks it on
incoming packets to distinguish between BFD failures caused by
control plane disruptions and those caused by data plane failures.
Consequently, a BFD-down event caused by a control plane restart on the
peer does not tear down the BGP session if the peer is still forwarding
traffic.
Without this option, every BFD-down event resets the BGP session.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 bfd check-control-plane-failure
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> bfd strict
**Require BFD to be up before the BGP session with the specified peer
reaches the Established state (strict-mode BFD).**
Without strict mode, BGP establishes the session independently, and BFD
only monitors it once both are up. With strict mode, BGP delays session
establishment until BFD declares the path to the peer up. This prevents
the BGP session from being established over a path that BFD will
subsequently report as down.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 bfd strict
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> bfd strict hold-time \<1-4294967295\>
**Configure how long, in seconds, BGP waits before tearing down the
session after BFD reports the path down.**
This timer applies only when the BGP hold-time is `0`. Otherwise, a
BFD-down event causes immediate BGP session teardown.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 bfd strict hold-time 30
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> enforce-first-as
**Require that the first ASN in the AS_PATH of every UPDATE received
from the specified eBGP peer matches that peer's ASN.**
If the first ASN does not match, the UPDATE is rejected.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 enforce-first-as
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> path-attribute discard \<1-255\>
**Drop the specified BGP path attribute from incoming UPDATE messages
received from this peer.**
The UPDATE is then processed without that attribute. The number
`<1-255>` is the path attribute type code per the IANA BGP Path
Attributes registry.
Multiple attributes can be discarded by issuing the command repeatedly
with different numbers.
```
```{note}
The following attributes cannot be discarded: 1 (ORIGIN), 2 (AS_PATH),
3 (NEXT_HOP), 4 (MED), 8 (COMMUNITIES), 14 (MP_REACH_NLRI),
15 (MP_UNREACH_NLRI), and 16 (EXTENDED_COMMUNITIES).
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 path-attribute discard 128
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> path-attribute treat-as-withdraw \<1-255\>
**Treat any incoming UPDATE that contains the specified BGP path
attribute as a withdrawal of the routes it carries.**
Use this to recover gracefully when a peer advertises malformed or
unexpected attributes that would otherwise tear down the session.
```
```{note}
The following attributes cannot be specified: 1 (ORIGIN), 2 (AS_PATH),
3 (NEXT_HOP), 4 (MED), 8 (COMMUNITIES), 14 (MP_REACH_NLRI),
15 (MP_UNREACH_NLRI), and 16 (EXTENDED_COMMUNITIES).
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 path-attribute treat-as-withdraw 32
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> maximum-prefix-out \<1-4294967295\>
**Configure the maximum number of prefixes the local BGP speaker will
advertise to the specified peer.**
Unlike `maximum-prefix`, which limits inbound prefixes and tears down
the session when the limit is exceeded, `maximum-prefix-out` simply
stops sending additional prefixes outbound once the limit is reached.
The session remains up.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast maximum-prefix-out 5000
```
#### Peer groups
Peer groups serve two purposes. First, they simplify configuration:
parameters applied to a group are inherited by all its members, so
common settings have to be configured only once and in one place.
Second, they improve scalability by computing outgoing update
information once per group rather than for each group member.
As a side effect, a route advertised by one group member is
re-advertised to all group members, including the sender itself. The
originator identifier attribute is included in such updates so that the
originating peer can recognize its own routes and ignore them.
Peers not explicitly assigned to any peer group are treated as members
of the default peer group and share updates with that group.
```{cfgcmd} set protocols bgp peer-group \<name\>
**Configure a BGP peer group.**
A peer group accepts the same parameters that can be applied to
individual neighbors.
```
```{note}
A parameter applied directly to an individual neighbor IP address
overrides the same parameter applied to a peer group that includes that
neighbor.
```
Example:
```none
set protocols bgp peer-group UPSTREAM
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> peer-group \<name\>
**Assign the specified neighbor to a peer group.**
The neighbor inherits all parameters configured on the peer group.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 peer-group UPSTREAM
```
### Network advertisement configuration
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> network \<prefix\>
**Configure BGP to originate and advertise the specified IPv4 or IPv6
prefix.**
```
```{note}
By default, BGP advertises a prefix configured via the `network` statement
even if the prefix is not present in the routing table. To make BGP verify
that the prefix exists in the RIB before advertising it (the behavior of
some other vendors' routers), enable the `network-import-check` option.
```
Example:
```none
set protocols bgp address-family ipv4-unicast network 198.51.100.0/24
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> network \<prefix\> route-map \<name\>
**Apply a route-map to set attributes on, or suppress, the locally
originated network route.**
The `route-map` is evaluated when BGP originates the route and can set
communities, MED, LOCAL_PREF, or other path attributes on the originated
route. If the `route-map` denies the prefix, BGP does not originate the
route.
```
Example:
```none
set protocols bgp address-family ipv4-unicast network 198.51.100.0/24 route-map SET-COMMUNITY
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast network \<prefix\> path-limit \<0-255\>
**Configure the AS_PATHLIMIT attribute on the originated IPv6 route.**
The AS_PATHLIMIT attribute sets an upper bound on the number of ASes the
route may traverse before being dropped. A value of `0` disables the
limit.
```
Example:
```none
set protocols bgp address-family ipv6-unicast network 2001:db8::/48 path-limit 8
```
```{cfgcmd} set protocols bgp parameters network-import-check
**Configure BGP to verify that a prefix defined by the `network` command
exists in the routing table (RIB) before it is advertised to BGP peers.**
```
Example:
```none
set protocols bgp parameters network-import-check
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> default-originate [route-map \<name\>]
**Configure BGP to advertise a default route (`0.0.0.0/0` or `::/0`) to
the specified peer.**
By default, VyOS does not advertise a default route even if one is
present in the routing table.
When a `route-map` is used, the default route is only advertised if the
conditions specified in the `route-map` are met.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast default-originate
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> addpath-tx-all
**Configure BGP to use ADD-PATH to advertise every known path for each
prefix to the specified peer, not only the best path.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast addpath-tx-all
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> addpath-tx-per-as
**Configure BGP to use ADD-PATH to advertise the best path per
neighboring AS to the specified peer.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast addpath-tx-per-as
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> conditionally-advertise advertise-map \<name\>
**Configure BGP to advertise the prefixes allowed by the specified
`route-map` only when the `exist-map` or `non-exist-map` condition is
met.**
```
```{note}
This option must be used together with either
`conditionally-advertise exist-map` or
`conditionally-advertise non-exist-map`, as `advertise-map` alone does
not enable conditional advertisement.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast conditionally-advertise advertise-map BACKUP-ROUTES
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> conditionally-advertise exist-map \<name\>
**Specify the route-map that defines the trigger condition for
`advertise-map`.**
The condition is met when at least one prefix allowed by the specified
`route-map` is present in the BGP RIB.
```
```{note}
`exist-map` and `non-exist-map` are mutually exclusive.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast conditionally-advertise exist-map AGGREGATE-PRESENT
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> conditionally-advertise non-exist-map \<name\>
**Specify the route-map that defines the trigger condition for
`advertise-map`.**
The condition is met when no prefix allowed by the specified `route-map`
is present in the BGP RIB.
```
```{note}
`exist-map` and `non-exist-map` are mutually exclusive.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast conditionally-advertise non-exist-map PRIMARY-UP
```
### Route aggregation configuration
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> aggregate-address \<prefix\>
**Configure BGP to advertise an aggregate route for the specified IPv4
or IPv6 prefix.**
By default, BGP also advertises more-specific routes that fall within
the aggregate.
```
Example:
```none
set protocols bgp address-family ipv4-unicast aggregate-address 198.51.100.0/22
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> aggregate-address \<prefix\> as-set
**Configure BGP to advertise an aggregate route with an AS_SET segment
in its AS_PATH for the specified IPv4 or IPv6 prefix.**
The AS_SET contains the AS numbers from the AS_PATHs of all contributing
more specific routes.
```
Example:
```none
set protocols bgp address-family ipv4-unicast aggregate-address 198.51.100.0/22 as-set
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> aggregate-address \<prefix\> summary-only
**Configure BGP to advertise only the aggregate route and suppress
advertisement of more-specific contributing routes.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast aggregate-address 198.51.100.0/22 summary-only
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> aggregate-address \<prefix\> route-map \<name\>
**Apply a `route-map` to set or modify BGP path attributes on the aggregate
route before it is advertised.**
Attribute changes apply only to the aggregate route and do not affect more
specific contributing routes. Use the `route-map` to set communities, MED,
LOCAL_PREF, or other attributes carried by the summary advertisement.
```
Example:
```none
set protocols bgp address-family ipv4-unicast aggregate-address 198.51.100.0/22 route-map AGGREGATE-ATTRS
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> unsuppress-map \<name\>
**Apply a route-map to selectively advertise to the specified peer
more specific routes that were suppressed by the `summary-only` option.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast unsuppress-map UNSUPPRESS-MORE-SPECIFIC
```
### Redistribution configuration
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospf | rip | static\>
**Redistribute IPv4 unicast routes from the specified source into BGP.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute connected
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute table \<id\>
**Redistribute IPv4 routes from the specified non-main kernel routing
table (identified by `<id>`, configured under
`set protocols static table`) into the BGP IPv4 unicast address family.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute table 100
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospfv3 | ripng | static\>
**Redistribute IPv6 unicast routes from the specified source into BGP.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute connected
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute table \<id\>
**Redistribute IPv6 routes from the specified non-main kernel routing
table (identified by `<id>`, configured under
`set protocols static table`) into the BGP IPv6 unicast address family.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute table 100
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospf | rip | static\> metric \<1-4294967295\>
**Redistribute IPv4 unicast routes from the specified source into BGP,
setting the MED attribute on the redistributed routes to the specified
value.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute static metric 100
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute table \<id\> metric \<1-4294967295\>
**Redistribute IPv4 routes from the specified non-main kernel routing
table into the BGP IPv4 unicast address family, setting the MED attribute
on the redistributed routes to the specified value.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute table 100 metric 100
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospfv3 | ripng | static\> metric \<1-4294967295\>
**Redistribute IPv6 unicast routes from the specified source into BGP,
setting the MED attribute on the redistributed routes to the specified
value.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute static metric 100
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute table \<id\> metric \<1-4294967295\>
**Redistribute IPv6 routes from the specified non-main kernel routing
table into the BGP IPv6 unicast address family, setting the MED attribute
on the redistributed routes to the specified value.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute table 100 metric 100
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospf | rip | static\> route-map \<name\>
**Apply a route-map to filter and modify IPv4 unicast routes
redistributed from the specified source.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute static route-map FILTER-STATIC
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast redistribute table \<id\> route-map \<name\>
**Apply a `route-map` to filter and modify IPv4 routes redistributed from
the specified non-main kernel routing table into the BGP IPv4 unicast
address family.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast redistribute table 100 route-map FILTER-STATIC
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute \<babel | connected | isis | kernel | nhrp | ospfv3 | ripng | static\> route-map \<name\>
**Apply a `route-map` to filter and modify IPv6 unicast routes
redistributed from the specified source.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute static route-map FILTER-STATIC
```
```{cfgcmd} set protocols bgp address-family ipv6-unicast redistribute table \<id\> route-map \<name\>
**Apply a `route-map` to filter and modify IPv6 routes redistributed from
the specified non-main kernel routing table into the BGP IPv6 unicast
address family.**
```
Example:
```none
set protocols bgp address-family ipv6-unicast redistribute table 100 route-map FILTER-STATIC
```
### General configuration
#### Common parameters
```{cfgcmd} set protocols bgp parameters allow-martian-nexthop
**Configure BGP to accept UPDATE messages whose NEXT_HOP attribute is
a Martian address.**
A Martian address is one that cannot legitimately appear as a BGP
next hop, such as an all-zero or unspecified address (e.g., `0.0.0.0/8`
or `::`), a loopback address (e.g., `127.0.0.0/8` or `::1`), a
multicast address, or an address of the local router itself.
By default, BGP rejects such routes.
```
Example:
```none
set protocols bgp parameters allow-martian-nexthop
```
```{cfgcmd} set protocols bgp parameters router-id \<id\>
**Configure the BGP router-ID as a 32-bit identifier in IPv4 address
notation.**
If no router ID is configured, VyOS uses the highest IPv4 address on the
loopback interface. If no loopback address is configured, VyOS uses the
highest IPv4 address on any other interface.
```
Example:
```none
set protocols bgp parameters router-id 192.0.2.1
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> maximum-paths \<ebgp | ibgp\> \<1-256\>
**Configure the maximum number of parallel BGP paths that can be
installed for the same destination
({abbr}`ECMP (Equal-Cost Multi-Path)`).**
For paths to be considered equal for multipath purposes, the following
must match: weight, local preference, AS_PATH content and length, origin
code, MED, and IGP metric. Each path must also have a distinct next hop
IP address.
```
Example:
```none
set protocols bgp address-family ipv4-unicast maximum-paths ebgp 4
```
```{cfgcmd} set protocols bgp parameters no-hard-administrative-reset
**Suppress sending a Hard Reset CEASE notification for Administrative
Reset events.**
When this option is enabled, routes are retained across an administrative
reset, provided the Graceful Restart Notification capability has been
negotiated between the peers.
```
Example:
```none
set protocols bgp parameters no-hard-administrative-reset
```
```{cfgcmd} set protocols bgp parameters log-neighbor-changes
**Configure BGP to log neighbor up/down state changes and reset reasons
to syslog.**
```
Example:
```none
set protocols bgp parameters log-neighbor-changes
```
```{cfgcmd} set protocols bgp parameters no-client-to-client-reflection
**Disable route reflection between route-reflector clients on this
router.**
By default, a route reflector reflects routes received from one client
to all other clients. If the clients are fully meshed with iBGP, this
reflection is unnecessary and can be disabled with this option.
```
Example:
```none
set protocols bgp parameters no-client-to-client-reflection
```
```{cfgcmd} set protocols bgp parameters no-fast-external-failover
**Disable immediate session reset when the connected link to an eBGP
peer goes down.**
By default, BGP resets the session immediately on link-down events. With
this option set, the session is held until the hold timer expires.
```
Example:
```none
set protocols bgp parameters no-fast-external-failover
```
```{cfgcmd} set protocols bgp parameters no-ipv6-auto-ra
**Suppress automatic IPv6 Router Advertisement (RA) on interfaces used
for BGP.**
By default, FRR sends RAs on an interface when its BGP session has
negotiated the Extended Next Hop capability, or when a BGP neighbor is
configured by interface name (Unnumbered BGP).
```
```{note}
Setting this option may prevent Unnumbered BGP sessions from
establishing.
```
Example:
```none
set protocols bgp parameters no-ipv6-auto-ra
```
```{cfgcmd} set protocols bgp listen range \<prefix\> peer-group \<name\>
**Configure BGP to accept inbound connections from any source IP address
within the specified prefix and associate them with the specified peer
group.**
This removes the need to statically define each BGP neighbor. When a TCP
connection and OPEN message arrive from a source IP address within the
specified prefix, the local router accepts the session using the peer
group's parameters.
```
```{note}
For each listen range, the referenced peer group must exist before the
configuration is committed.
```
Example:
```none
set protocols bgp listen range 192.0.2.0/24 peer-group UPSTREAM
```
```{cfgcmd} set protocols bgp listen limit \<1-5000\>
**Configure the maximum number of dynamic BGP neighbors the local router
will accept via configured listen ranges.**
```
Example:
```none
set protocols bgp listen limit 100
```
```{cfgcmd} set protocols bgp parameters ebgp-requires-policy
**Require an explicit policy in each direction on eBGP sessions before
exchanging routes
([RFC 8212](https://datatracker.ietf.org/doc/html/rfc8212)).**
By default, VyOS disables this RFC 8212 behavior for backward
compatibility with older VyOS versions. Enabling it brings VyOS into
compliance with the default route propagation behavior expected by
RFC 8212.
```
Example:
```none
set protocols bgp parameters ebgp-requires-policy
```
```{cfgcmd} set protocols bgp parameters labeled-unicast \<explicit-null | ipv4-explicit-null | ipv6-explicit-null\>
**Configure {abbr}`BGP-LU (BGP Labeled Unicast)` to advertise locally
originated prefixes with an explicit-null label instead of the default
implicit-null label, preserving the MPLS label at the egress.**
```
Example:
```none
set protocols bgp parameters labeled-unicast explicit-null
```
<!-- CLI path not accepted on live VyOS
```{cfgcmd} set protocols bgp parameters as-notation \<asdot | asdot+ | asplain\>
- `asplain`: Print every ASN in plain decimal. This is the default.
- `asdot`: Print ASNs greater than 65535 in dotted notation (e.g.,
`65540` becomes `1.4`). ASNs at or below 65535 are printed in plain
decimal.
- `asdot+`: Print every ASN in dotted notation.
```
Example:
```none
set protocols bgp parameters as-notation asdot
```
-->
```{cfgcmd} set protocols bgp parameters disable-ebgp-connected-route-check
**Allow eBGP-learned routes whose NEXT_HOP is not directly connected to
be installed in the RIB.**
By default, BGP requires the next hop of an eBGP-learned route to be
reachable through a directly connected route. This option removes
that restriction.
```
Example:
```none
set protocols bgp parameters disable-ebgp-connected-route-check
```
```{cfgcmd} set protocols bgp parameters fast-convergence
**Configure BGP to tear down its sessions immediately whenever the
local router detects that a peer has become unreachable.**
This triggers on both direct link-down events and NEXT_HOP reachability
changes signaled by the IGP.
```
Example:
```none
set protocols bgp parameters fast-convergence
```
```{cfgcmd} set protocols bgp parameters no-suppress-duplicates
**Disable suppression of duplicate UPDATE messages for routes whose
attributes have not changed.**
By default, BGP suppresses repeated advertisements of the same route
with unchanged attributes. Setting this option disables that
suppression.
```
Example:
```none
set protocols bgp parameters no-suppress-duplicates
```
```{cfgcmd} set protocols bgp parameters reject-as-sets
**Configure BGP to reject incoming UPDATE messages whose AS_PATH
contains an AS_SET or AS_CONFED_SET segment.**
AS_SET segments are deprecated for most modern deployments.
```
Example:
```none
set protocols bgp parameters reject-as-sets
```
```{cfgcmd} set protocols bgp parameters suppress-fib-pending
**Configure BGP not to advertise a route to peers until the route is
installed in the kernel forwarding table (FIB).**
This prevents the local router from advertising a route it cannot yet
forward.
```
Example:
```none
set protocols bgp parameters suppress-fib-pending
```
```{cfgcmd} set protocols bgp parameters shutdown
**Administratively shut down the entire BGP instance on this router.**
This terminates all BGP sessions belonging to this instance.
```
Example:
```none
set protocols bgp parameters shutdown
```
```{cfgcmd} set protocols bgp parameters input-queue-limit \<messages\>
**Set the BGP input queue limit for all peers during message parsing.**
Increase this only if you have the memory to handle large queues of
messages at once. The default is 10000.
```
Example:
```none
set protocols bgp parameters input-queue-limit 10000
```
```{cfgcmd} set protocols bgp parameters output-queue-limit \<messages\>
**Set the BGP output queue limit for all peers during message parsing.**
Increase this only if you have the memory to handle large queues of
messages at once. The default is 10000.
```
Example:
```none
set protocols bgp parameters output-queue-limit 10000
```
#### Graceful restart and shutdown
```{cfgcmd} set protocols bgp parameters graceful-restart stalepath-time \<1-3600\>
**Configure the maximum time, in seconds, that the local router retains
stale routes from a restarting peer.**
When a BGP peer signals Graceful Restart, the local router marks the
peer's routes as stale and continues forwarding traffic on them while
the session is down. If the peer does not complete the Graceful Restart
(re-establish the session and send the End-of-RIB marker) within
`stalepath-time`, the stale routes are removed.
```
Example:
```none
set protocols bgp parameters graceful-restart stalepath-time 360
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> graceful-restart \<enable | disable | restart-helper\>
**Configure the Graceful Restart role for the specified peer:**
- `enable`: Advertises the GR capability and allows both restart and
helper roles.
- `disable`: Disables GR for this peer.
- `restart-helper`: Advertises only the helper role. The local router
retains the peer's routes across a peer restart but does not advertise
the restart capability for itself.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 graceful-restart restart-helper
```
```{cfgcmd} set protocols bgp parameters graceful-shutdown
**Configure BGP to tag all outbound routes with the GRACEFUL_SHUTDOWN
community, signaling to neighbors that they should prefer alternative
paths.**
```
Example:
```none
set protocols bgp parameters graceful-shutdown
```
#### Administrative distance
```{cfgcmd} set protocols bgp parameters distance global \<external | internal | local\> \<1-255\>
**Configure the administrative distance assigned to BGP routes of the
specified category.**
`external` covers eBGP-learned routes, `internal` covers iBGP-learned
routes, and `local` covers locally originated BGP routes.
```
Example:
```none
set protocols bgp parameters distance global external 20
```
```{cfgcmd} set protocols bgp parameters distance prefix \<subnet\> distance \<1-255\>
**Override the BGP administrative distance for routes matching the
specified prefix.**
```
```{note}
A distance value of 255 effectively disables the route. It is not
installed in the kernel forwarding table.
```
Example:
```none
set protocols bgp parameters distance prefix 198.51.100.0/24 distance 200
```
The commands above set process-wide BGP distances under `parameters
distance`. Per-address-family distances can also be configured under each
`address-family` node and override the process-wide values for routes in
that address family.
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> distance \<external | internal | local\> \<1-255\>
**Configure the administrative distance assigned to BGP routes of the
specified category within the selected address family.**
`external` covers eBGP-learned routes, `internal` covers iBGP-learned
routes, and `local` covers locally originated BGP routes.
Per-address-family values configured here override the corresponding
values set by `set protocols bgp parameters distance global` for that
address family.
```
Example:
```none
set protocols bgp address-family ipv4-unicast distance external 20
```
```{cfgcmd} set protocols bgp address-family \<ipv4-unicast | ipv6-unicast\> distance prefix \<subnet\> distance \<1-255\>
**Override the BGP administrative distance for routes matching the
specified prefix within the selected address family.**
Per-address-family values configured here override the corresponding
values set by `set protocols bgp parameters distance prefix` for that
address family.
```
```{note}
A distance value of 255 effectively disables the route. It is not
installed in the kernel forwarding table.
```
Example:
```none
set protocols bgp address-family ipv4-unicast distance prefix 198.51.100.0/24 distance 200
```
#### Timers
```{cfgcmd} set protocols bgp timers holdtime \<0-65535\>
**Configure the BGP hold time, in seconds.**
The default is 180 seconds. Setting the value to 0 disables the hold
timer and keepalive exchange entirely.
[RFC 4271](https://datatracker.ietf.org/doc/html/rfc4271) section 4.2
requires the Hold Time to be either 0 or at least 3 seconds; the VyOS
CLI accepts values of 1 and 2, but a session established with such a
value will not be standards-compliant.
```
Example:
```none
set protocols bgp timers holdtime 90
```
```{cfgcmd} set protocols bgp timers keepalive \<1-65535\>
**Configure the BGP keepalive interval, in seconds.**
```
Example:
```none
set protocols bgp timers keepalive 30
```
```{cfgcmd} set protocols bgp parameters minimum-holdtime \<1-65535\>
**Configure BGP to reject incoming OPEN messages from peers that
propose a hold time shorter than the specified value, in seconds.**
```
Example:
```none
set protocols bgp parameters minimum-holdtime 30
```
```{cfgcmd} set protocols bgp parameters tcp-keepalive idle \<1-65535\>
**Configure the TCP keepalive idle time, in seconds, on BGP sessions.**
Once no TCP packets have been exchanged in either direction on the BGP
session for this period, the BGP process starts sending TCP keepalive
probes.
```
```{note}
Must be set together with `tcp-keepalive interval` and
`tcp-keepalive probes`.
```
Example:
```none
set protocols bgp parameters tcp-keepalive idle 60
```
```{cfgcmd} set protocols bgp parameters tcp-keepalive interval \<1-65535\>
**Configure the interval, in seconds, between TCP keepalive probes on
BGP sessions.**
After the BGP process begins sending TCP keepalive probes (see
`tcp-keepalive idle`), subsequent probes are sent at this interval.
```
```{note}
Must be set together with `tcp-keepalive idle` and
`tcp-keepalive probes`.
```
Example:
```none
set protocols bgp parameters tcp-keepalive interval 10
```
```{cfgcmd} set protocols bgp parameters tcp-keepalive probes \<1-30\>
**Configure the maximum number of unanswered TCP keepalive probes
before the TCP connection is dropped.**
```
```{note}
Must be set together with `tcp-keepalive idle` and
`tcp-keepalive interval`.
```
Example:
```none
set protocols bgp parameters tcp-keepalive probes 5
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> timers holdtime \<0-65535\>
**Override the BGP hold time for the specified peer, in seconds.**
This option takes precedence over the process-wide `set protocols bgp
timers holdtime`. Setting the value to `0` disables the hold timer and
keepalive exchange for this peer.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 timers holdtime 30
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> timers keepalive \<1-65535\>
**Override the BGP keepalive interval for the specified peer, in
seconds.**
This option takes precedence over the process-wide `set protocols bgp
timers keepalive`.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 timers keepalive 10
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> timers connect \<0-65535\>
**Configure the BGP ConnectRetry timer for the specified peer, in
seconds.**
This is the interval the local BGP speaker waits between TCP connection
attempts to a peer that is not yet in the Established state. Setting the
value to `0` disables the ConnectRetry timer.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 timers connect 5
```
#### BGP read-only mode
```{cfgcmd} set protocols bgp parameters update-delay max-delay \<0-3600\>
**Enable BGP read-only mode after a BGP process restart or after clearing
all BGP sessions, and configure the mode's maximum delay.**
In read-only mode, BGP suspends best-path selection and does not send
routing updates to peers. The mode ends when the router receives all
expected {abbr}`EOR (End-of-RIB)` messages from BGP peers or when the
maximum delay is reached, whichever occurs first.
The router expects EOR messages from all configured BGP peers except
those that are administratively shut down. If the `establish-wait`
parameter is configured, the router waits for EOR messages only from BGP
peers that reach the Established state within the `establish-wait`
window.
By default, BGP read-only mode is disabled.
```
Example:
```none
set protocols bgp parameters update-delay max-delay 120
```
```{cfgcmd} set protocols bgp parameters update-delay establish-wait \<1-3600\>
**Configure how long the router waits for BGP peers to reach the
Established state after read-only mode begins.**
The router waits for EOR messages only from BGP peers that reach the
Established state within the `establish-wait` window. The
`establish-wait` value must not exceed the `max-delay` value.
```
```{note}
This parameter requires `max-delay` to be configured.
```
Example:
```none
set protocols bgp parameters update-delay establish-wait 90
```
#### Route dampening
When a route fails, a withdrawal update is sent across the network. When
the route returns, an advertisement is sent. A route that repeatedly
fails and returns (flaps) generates substantial protocol traffic.
Route dampening, described in
[RFC 2439](https://datatracker.ietf.org/doc/html/rfc2439), identifies
unstable routes and suppresses them. Each time a route flaps, it incurs a
penalty (1000 per flap). When the accumulated penalty exceeds the
suppress threshold, the router stops advertising the route.
The penalty decays exponentially over time (halving every half-life
interval). When it drops below the reuse threshold, the route is
unsuppressed and becomes eligible for advertisement and use again. No
route is suppressed indefinitely. The `max-suppress-time` is the upper
bound on suppression duration.
```{cfgcmd} set protocols bgp parameters dampening half-life \<1-45\>
**Configure the route dampening half-life, in minutes.**
This is the interval over which a route's accumulated penalty is halved.
```
Example:
```none
set protocols bgp parameters dampening half-life 15
```
```{cfgcmd} set protocols bgp parameters dampening re-use \<1-20000\>
**Configure the penalty threshold below which a suppressed route is
reused.**
Once the decaying penalty falls below this value, the route becomes
eligible for use and is advertised to peers again.
```
Example:
```none
set protocols bgp parameters dampening re-use 750
```
```{cfgcmd} set protocols bgp parameters dampening start-suppress-time \<1-20000\>
**Configure the penalty threshold above which a route is suppressed.**
Once a route's accumulated penalty exceeds this value, it is no longer
advertised to peers or used locally until the penalty decays below the
reuse threshold.
```
Example:
```none
set protocols bgp parameters dampening start-suppress-time 2000
```
```{cfgcmd} set protocols bgp parameters dampening max-suppress-time \<1-255\>
**Configure the maximum time, in minutes, that a route may remain
suppressed by dampening.**
Once this limit is reached, the route becomes eligible for use and
advertisement again, regardless of its remaining penalty.
```
Example:
```none
set protocols bgp parameters dampening max-suppress-time 60
```
#### Route selection configuration
```{cfgcmd} set protocols bgp parameters always-compare-med
**Configure BGP to compare the MED attribute between routes received
from different neighboring ASs during best-path selection.**
By default, MED is only compared between routes received from the same
neighboring AS.
```
```{note}
Setting this option can make path selection more predictable, but it
does not prevent MED-induced oscillation and can cause it in some
topologies.
```
Example:
```none
set protocols bgp parameters always-compare-med
```
```{cfgcmd} set protocols bgp parameters bestpath as-path confed
**Configure BGP to include the length of confederation path segments
(AS_CONFED_SEQUENCE and AS_CONFED_SET) in the AS_PATH length used during
best-path selection.**
By default, these segments are not counted.
```
Example:
```none
set protocols bgp parameters bestpath as-path confed
```
```{cfgcmd} set protocols bgp parameters bestpath as-path multipath-relax
**Configure BGP to treat paths with equal AS_PATH length but different
AS_PATH content as equal for load balancing.**
Without this option, the entire AS_PATH content must match.
```
Example:
```none
set protocols bgp parameters bestpath as-path multipath-relax
```
```{cfgcmd} set protocols bgp parameters bestpath as-path ignore
**Configure BGP to ignore AS_PATH length entirely during best-path
selection.**
```
Example:
```none
set protocols bgp parameters bestpath as-path ignore
```
```{cfgcmd} set protocols bgp parameters bestpath compare-routerid
**Configure BGP to use the lowest router ID as the tie-breaker between
otherwise-equal eBGP routes, instead of the already-selected check.**
When this option is enabled, the already-selected check is skipped. If a
route has been reflected (i.e., has an ORIGINATOR_ID attribute), that
value is used. Otherwise, the router-ID of the peer that sent the route
is used.
The advantage is that route selection becomes more deterministic. The
disadvantage is that a single low-ID router may attract traffic that
would otherwise be spread across multiple equal-cost paths. The option
can also increase the risk of MED- or IGP-induced oscillation. The exact
behavior is sensitive to the iBGP and reflection topology.
```
Example:
```none
set protocols bgp parameters bestpath compare-routerid
```
```{cfgcmd} set protocols bgp parameters bestpath med confed
**Configure BGP to consider the MED attribute when comparing routes
received via different sub-ASs within the same BGP confederation.**
By default, MED is only compared between routes received from the same
sub-AS.
```
Example:
```none
set protocols bgp parameters bestpath med confed
```
```{cfgcmd} set protocols bgp parameters bestpath med missing-as-worst
**Configure BGP to treat a missing MED attribute as the worst possible
value during best-path selection.**
By default, a missing MED is treated as 0, the best possible value.
```
Example:
```none
set protocols bgp parameters bestpath med missing-as-worst
```
```{cfgcmd} set protocols bgp parameters default local-pref \<0-4294967295\>
**Configure the default LOCAL_PREF value assigned to eBGP-learned and
locally-originated routes.**
iBGP-learned routes always carry LOCAL_PREF and are not affected.
```
Example:
```none
set protocols bgp parameters default local-pref 100
```
```{cfgcmd} set protocols bgp parameters deterministic-med
**Configure BGP to group routes by the neighboring AS (the AS the route
was received from) before comparing MED values during best-path
selection.**
When configured, BGP first selects the best route within each
neighbor-AS group and then compares those per-AS bests.
```
Example:
```none
set protocols bgp parameters deterministic-med
```
```{cfgcmd} set protocols bgp address-family ipv4-unicast network \<prefix\> backdoor
**Mark the specified IPv4 prefix as a backdoor route so that an IGP path
to it is preferred over an eBGP-learned path.**
```
Example:
```none
set protocols bgp address-family ipv4-unicast network 198.51.100.0/24 backdoor
```
```{cfgcmd} set protocols bgp parameters bestpath bandwidth \<default-weight-for-missing | ignore | skip-missing\>
**Configure how BGP uses the Link Bandwidth extended community in
weighted-ECMP load balancing:**
- `default-weight-for-missing`: Assigns a low default weight (1) to
paths that do not carry a link bandwidth attribute.
- `ignore`: Disables weighted ECMP entirely and uses regular ECMP.
- `skip-missing`: Excludes paths without link bandwidth from ECMP when
at least one other path carries it.
```
Example:
```none
set protocols bgp parameters bestpath bandwidth skip-missing
```
```{cfgcmd} set protocols bgp parameters bestpath peer-type multipath-relax
**Configure BGP to allow load sharing across paths learned from
different peer types (eBGP and iBGP) for the same destination.**
Without this option, multipath is restricted to peers of the same type
(eBGP-only or iBGP-only).
```
Example:
```none
set protocols bgp parameters bestpath peer-type multipath-relax
```
```{cfgcmd} set protocols bgp parameters conditional-advertisement timer \<5-240\>
**Configure the interval, in seconds, at which the BGP process
re-evaluates `conditionally-advertise` conditions.**
The default is 60 seconds.
```
Example:
```none
set protocols bgp parameters conditional-advertisement timer 30
```
### Route filtering configuration
To control and modify routing information exchanged between peers, you
can use a `route-map`, `filter-list`, `prefix-list`, or `distribute-list`.
Inbound updates are evaluated in the following order: `route-map`,
`filter-list`, then either `prefix-list` or `distribute-list`. Outbound
updates are evaluated in the following order: either `prefix-list` or
`distribute-list`, `filter-list`, then `route-map`.
```{note}
`prefix-list` and `distribute-list` are mutually exclusive. Only one of
the two can be applied to each inbound or outbound direction for a
particular neighbor.
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> distribute-list \<export | import\> \<1-65535\>
**Apply the specified `access-list` to filter routing information received
from or advertised to the specified peer.**
`export` applies the filter to outbound advertisements, and `import`
applies it to inbound updates.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast distribute-list import 10
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> prefix-list \<export | import\> \<name\>
**Apply the specified `prefix-list` to filter routing information received
from or advertised to the specified peer.**
`export` applies the filter to outbound advertisements, and `import`
applies it to inbound updates.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast prefix-list import PEER-IN
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> route-map \<export | import\> \<name\>
**Apply the specified `route-map` to control and modify routing
information received from or advertised to the specified peer.**
`export` applies the `route-map` to outbound advertisements, and `import`
applies it to inbound updates.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast route-map import PEER-IN
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> filter-list \<export | import\> \<name\>
**Apply the specified AS-path access-list to filter routing information
received from or advertised to the specified peer.**
`export` applies the filter to outbound advertisements, and `import`
applies it to inbound updates.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast filter-list import AS-PATH-IN
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> capability orf prefix-list \<receive | send\>
**Enable the {abbr}`ORF (Outbound Route Filter)` capability on the
local router and advertise it to the specified peer.**
`receive` configures the router to accept ORF filters sent by the peer
and use them to filter its own outbound updates. `send` configures the
router to push its inbound prefix-list to the peer as an ORF, so the
peer can filter its outbound updates before sending them.
```
```{note}
To use the `send` option, an inbound prefix-list must already be
configured for that peer on this router.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast capability orf prefix-list send
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> solo
**Prevent the local BGP speaker from advertising prefixes learned from
the specified neighbor back to that neighbor.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 solo
```
```{cfgcmd} set protocols bgp neighbor \<address | interface\> address-family \<ipv4-unicast | ipv6-unicast\> route-server-client
**Configure the specified neighbor as a route-server client.**
A route server, typically deployed at internet exchange points, peers
with many participants and redistributes their routes between them
while leaving AS_PATH, NEXT_HOP, and other BGP attributes untouched.
Configuring a peer as `route-server-client` suppresses the standard
eBGP outbound rewrites of these attributes for that peer.
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast route-server-client
```
### BGP scaling configuration
Within an autonomous system (AS), BGP routers form iBGP sessions. To
prevent routing loops, an iBGP speaker does not re-advertise iBGP-learned
routes to other iBGP speakers. Consequently, iBGP requires a full mesh of
sessions between all speakers, which scales poorly in large networks.
The following mechanisms allow you to eliminate the need for a full iBGP
mesh: route reflectors and confederations.
#### Route reflector configuration
{abbr}`RRs (Route Reflectors)` eliminate the need for a full iBGP mesh
between clients.
A route reflector treats its iBGP peers as either clients (whose routes
are reflected to other clients and non-clients) or non-clients (regular
iBGP peers, which still require a full mesh among themselves). The route
reflector mechanism is described in
[RFC 4456](https://datatracker.ietf.org/doc/html/rfc4456), with later
refinements to error handling in
[RFC 7606](https://datatracker.ietf.org/doc/html/rfc7606).
```{cfgcmd} set protocols bgp neighbor \<address\> address-family \<ipv4-unicast | ipv6-unicast\> route-reflector-client
**Configure the specified neighbor as a route-reflector client for the
selected address family.**
```
Example:
```none
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast route-reflector-client
```
```{cfgcmd} set protocols bgp parameters cluster-id \<id\>
**Configure the BGP cluster-ID used by route reflectors to identify a
collection of reflectors and clients and to detect reflection loops.**
By default, the cluster-ID is set to the BGP router-ID. It can be
overridden with any 32-bit value in IPv4 address notation.
```
Example:
```none
set protocols bgp parameters cluster-id 192.0.2.10
```
```{cfgcmd} set protocols bgp parameters route-reflector-allow-outbound-policy
**Allow outbound route-maps (and other outbound policy) to apply to
routes the local route reflector reflects to its route reflector
clients.**
By default, FRR does not apply outbound policy to reflected routes, to
preserve the reflector's transparency. Enabling this option allows
outbound policy to take effect on reflected routes.
```
Example:
```none
set protocols bgp parameters route-reflector-allow-outbound-policy
```
#### Confederation configuration
A BGP confederation divides an AS into sub-ASs (member-ASs) to reduce the
number of required iBGP peerings. Within each sub-AS, a full iBGP mesh is
still required. Between sub-ASs, speakers use intra-confederation eBGP
sessions that preserve iBGP-style handling of NEXT_HOP, LOCAL_PREF, and
MED.
The confederation mechanism is described in
[RFC 5065](https://datatracker.ietf.org/doc/html/rfc5065).
```{cfgcmd} set protocols bgp parameters confederation identifier \<1-4294967294\>
**Configure the externally visible BGP confederation identifier (the ASN
that the entire confederation presents to other autonomous systems).**
```
Example:
```none
set protocols bgp parameters confederation identifier 65000
```
```{cfgcmd} set protocols bgp parameters confederation peers \<1-4294967294\>
**Configure the ASNs of other (not local) sub-ASs within the same BGP
confederation.**
This command is multi-value: issue it once per remote sub-AS to add each
member-AS to the confederation peer list. The local sub-AS (configured
via `system-as`) must not be listed here.
```
Example:
```none
set protocols bgp parameters confederation peers 65001
set protocols bgp parameters confederation peers 65002
set protocols bgp parameters confederation peers 65003
```
## Operation
### Show
```{opcmd} show bgp \<ipv4 | ipv6\>
**Show the BGP routing table for the specified address family.**
```
Example output:
```none
BGP table version is 10, local router ID is 192.0.2.3, vrf id 0
Default local pref 100, local AS 64496
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
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 198.51.100.0/24 192.0.2.4 0 0 64500 i
*> 203.0.113.0/24 192.0.2.5 0 0 64501 i
Displayed 2 routes and 2 total paths
```
```{opcmd} show bgp \<ipv4 | ipv6\> \<address | prefix\>
**Show detailed BGP information for the specified prefix.**
```
Example output:
```none
BGP routing table entry for 198.51.100.0/24
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
192.0.2.1 192.0.2.2 192.0.2.4 192.0.2.5
64504
192.0.2.4 from 192.0.2.4 (192.0.2.4)
Origin IGP, metric 0, valid, external, best (First path received)
Last update: Wed Jan 6 12:18:53 2021
```
```{opcmd} show bgp cidr-only
**Show BGP routes with non-natural (non-classful) prefix lengths.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> community \<value\>
**Show BGP routes carrying the specified community value in their
COMMUNITIES attribute.**
Valid values are:
- a decimal number (1-4294967200)
- an `AA:NN` pair, where `AA` is an autonomous system number, and `NN`
is a 2-byte community value (e.g., `65001:100`)
- one of the well-known community names, such as `no-export`,
`no-advertise`, or `local-as`.
```
```{opcmd} show bgp \<ipv4 | ipv6\> community-list \<name\>
**Show BGP routes permitted by the specified community-list.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> dampening dampened-paths
**Show BGP routes currently suppressed by dampening.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> dampening flap-statistics
**Show flap statistics for BGP routes tracked by dampening (any route
with an accumulated penalty).**
```
```{opcmd} show bgp \<ipv4 | ipv6\> filter-list \<name\>
**Show BGP routes permitted by the specified AS-path access-list.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> neighbors \<address\> advertised-routes
**Show the BGP routes advertised by the local router to the specified
neighbor.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> neighbors \<address\> received-routes
**Show the BGP routes received from the specified neighbor before the
inbound policy is applied.**
Requires inbound `soft-reconfiguration` to be enabled for that neighbor
on the local router.
```
```{opcmd} show bgp \<ipv4 | ipv6\> neighbors \<address\> routes
**Show the BGP routes received from the specified neighbor that were
accepted after inbound filtering.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> neighbors \<address\> dampened-routes
**Show dampened BGP routes received from the specified neighbor.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> regexp \<text\>
**Show BGP routes whose AS_PATH matches the specified regular
expression.**
```
```{opcmd} show bgp \<ipv4 | ipv6\> summary
**Show a summary of all BGP sessions.**
```
Example output:
```none
IPv4 Unicast Summary:
BGP router identifier 192.0.2.3, local AS number 64500 vrf-id 0
BGP table version 11
RIB entries 5, using 920 bytes of memory
Peers 4, using 82 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.1 4 64500 148 159 0 0 0 02:16:01 0
192.0.2.2 4 64500 136 143 0 0 0 02:13:21 0
192.0.2.4 4 64504 161 163 0 0 0 02:16:01 1
192.0.2.5 4 64505 162 166 0 0 0 02:16:01 1
Total number of neighbors 4
```
### Reset
```{opcmd} reset bgp \<ipv4 | ipv6\> \<address\> [soft [in | out]]
**Reset the BGP session with the specified neighbor.**
With `soft`, the router performs a soft reset rather than tearing down
the TCP session. Without `in` or `out`, soft reset is applied in both
directions.
```
```{opcmd} reset bgp all
**Reset all BGP sessions on this router.**
```
```{opcmd} reset bgp \<ipv4 | ipv6\> external
**Reset all external (eBGP) sessions on this router for the specified
address family.**
```
```{opcmd} reset bgp \<ipv4 | ipv6\> peer-group \<name\> [soft [in | out]]
**Reset BGP sessions with all members of the specified peer group.**
With `soft`, the router performs a soft reset rather than tearing down
the TCP sessions. Without `in` or `out`, soft reset is applied in both
directions.
```
## Examples
### IPv4 peering
The following example demonstrates a simple eBGP peering between two VyOS
routers.
**Node 1:**
```none
set protocols bgp system-as 64512
set protocols bgp neighbor 192.0.2.2 ebgp-multihop '2'
set protocols bgp neighbor 192.0.2.2 remote-as '64513'
set protocols bgp neighbor 192.0.2.2 update-source '192.0.2.1'
set protocols bgp neighbor 192.0.2.2 address-family ipv4-unicast
set protocols bgp address-family ipv4-unicast network '198.51.100.0/24'
set protocols bgp parameters router-id '192.0.2.1'
```
**Node 2:**
```none
set protocols bgp system-as 64513
set protocols bgp neighbor 192.0.2.1 ebgp-multihop '2'
set protocols bgp neighbor 192.0.2.1 remote-as '64512'
set protocols bgp neighbor 192.0.2.1 update-source '192.0.2.2'
set protocols bgp neighbor 192.0.2.1 address-family ipv4-unicast
set protocols bgp address-family ipv4-unicast network '203.0.113.0/24'
set protocols bgp parameters router-id '192.0.2.2'
```
The CIDR declared in the `network` statement must exist in the routing
table (either dynamic or static). The simplest way to ensure that is to
create a blackhole static route:
**Node 1:**
```none
set protocols static route 198.51.100.0/24 blackhole distance '254'
```
**Node 2:**
```none
set protocols static route 203.0.113.0/24 blackhole distance '254'
```
### IPv6 peering
The following example demonstrates a simple eBGP peering over IPv6.
**Node 1:**
```none
set protocols bgp system-as 64512
set protocols bgp neighbor 2001:db8::2 ebgp-multihop '2'
set protocols bgp neighbor 2001:db8::2 remote-as '64513'
set protocols bgp neighbor 2001:db8::2 update-source '2001:db8::1'
set protocols bgp neighbor 2001:db8::2 address-family ipv6-unicast
set protocols bgp address-family ipv6-unicast network '2001:db8:1::/48'
set protocols bgp parameters router-id '192.0.2.1'
```
**Node 2:**
```none
set protocols bgp system-as 64513
set protocols bgp neighbor 2001:db8::1 ebgp-multihop '2'
set protocols bgp neighbor 2001:db8::1 remote-as '64512'
set protocols bgp neighbor 2001:db8::1 update-source '2001:db8::2'
set protocols bgp neighbor 2001:db8::1 address-family ipv6-unicast
set protocols bgp address-family ipv6-unicast network '2001:db8:2::/48'
set protocols bgp parameters router-id '192.0.2.2'
```
As with IPv4, the prefix declared in the `network` statement must exist
in the routing table. A blackhole static route is the simplest way to
ensure this:
**Node 1:**
```none
set protocols static route6 2001:db8:1::/48 blackhole distance '254'
```
**Node 2:**
```none
set protocols static route6 2001:db8:2::/48 blackhole distance '254'
```
### Route filtering
The following example applies inbound and outbound route filters to both
IPv4 and IPv6 BGP sessions using route-maps that reference prefix-lists.
**Node 1:**
```none
set policy prefix-list AS64513-IN rule 10 action 'permit'
set policy prefix-list AS64513-IN rule 10 prefix '203.0.113.0/24'
set policy prefix-list AS64513-OUT rule 10 action 'deny'
set policy prefix-list AS64513-OUT rule 10 prefix '198.51.100.0/24'
set policy prefix-list6 AS64513-IN rule 10 action 'permit'
set policy prefix-list6 AS64513-IN rule 10 prefix '2001:db8:2::/48'
set policy prefix-list6 AS64513-OUT rule 10 action 'deny'
set policy prefix-list6 AS64513-OUT rule 10 prefix '2001:db8:1::/48'
set policy route-map AS64513-IN rule 10 action 'permit'
set policy route-map AS64513-IN rule 10 match ip address prefix-list 'AS64513-IN'
set policy route-map AS64513-IN rule 10 match ipv6 address prefix-list 'AS64513-IN'
set policy route-map AS64513-IN rule 20 action 'deny'
set policy route-map AS64513-OUT rule 10 action 'deny'
set policy route-map AS64513-OUT rule 10 match ip address prefix-list 'AS64513-OUT'
set policy route-map AS64513-OUT rule 10 match ipv6 address prefix-list 'AS64513-OUT'
set policy route-map AS64513-OUT rule 20 action 'permit'
set protocols bgp system-as 64512
set protocols bgp neighbor 2001:db8::2 address-family ipv4-unicast route-map export 'AS64513-OUT'
set protocols bgp neighbor 2001:db8::2 address-family ipv4-unicast route-map import 'AS64513-IN'
set protocols bgp neighbor 2001:db8::2 address-family ipv6-unicast route-map export 'AS64513-OUT'
set protocols bgp neighbor 2001:db8::2 address-family ipv6-unicast route-map import 'AS64513-IN'
```
**Node 2:**
```none
set policy prefix-list AS64512-IN rule 10 action 'permit'
set policy prefix-list AS64512-IN rule 10 prefix '198.51.100.0/24'
set policy prefix-list AS64512-OUT rule 10 action 'deny'
set policy prefix-list AS64512-OUT rule 10 prefix '203.0.113.0/24'
set policy prefix-list6 AS64512-IN rule 10 action 'permit'
set policy prefix-list6 AS64512-IN rule 10 prefix '2001:db8:1::/48'
set policy prefix-list6 AS64512-OUT rule 10 action 'deny'
set policy prefix-list6 AS64512-OUT rule 10 prefix '2001:db8:2::/48'
set policy route-map AS64512-IN rule 10 action 'permit'
set policy route-map AS64512-IN rule 10 match ip address prefix-list 'AS64512-IN'
set policy route-map AS64512-IN rule 10 match ipv6 address prefix-list 'AS64512-IN'
set policy route-map AS64512-IN rule 20 action 'deny'
set policy route-map AS64512-OUT rule 10 action 'deny'
set policy route-map AS64512-OUT rule 10 match ip address prefix-list 'AS64512-OUT'
set policy route-map AS64512-OUT rule 10 match ipv6 address prefix-list 'AS64512-OUT'
set policy route-map AS64512-OUT rule 20 action 'permit'
set protocols bgp system-as 64513
set protocols bgp neighbor 2001:db8::1 address-family ipv4-unicast route-map export 'AS64512-OUT'
set protocols bgp neighbor 2001:db8::1 address-family ipv4-unicast route-map import 'AS64512-IN'
set protocols bgp neighbor 2001:db8::1 address-family ipv6-unicast route-map export 'AS64512-OUT'
set protocols bgp neighbor 2001:db8::1 address-family ipv6-unicast route-map import 'AS64512-IN'
```
This pattern can be extended in the `rule 20` deny clauses to also
filter link-local and multicast prefixes.
|