В данной статье приведен пример конфигурации default-маршрута (0.0.0.0/0) средствами BGP.
В качестве примера рассмотрим схему включения, изображенную на рисунке 1.
Рисунок 1 - Схема включения.
Настройка адресации на интерфейсах не приведена.
Для начала настроим протокол динамической маршрутизации ISIS на маршрутизаторах: R2, R3, R5.
В качестве примера приведем настройку для маршрутизатора R2, для остальных маршрутизаторов конфигурация аналогична.
Маршрутизатор R2:
router isis 1 interface loopback 0 address-family ipv4 unicast exit passive exit interface tengigabitethernet 0/0/5.200 address-family ipv4 unicast bfd fast-detect exit level level-2 exit point-to-point exit interface tengigabitethernet 0/0/11.200 address-family ipv4 unicast bfd fast-detect exit level level-2 exit point-to-point exit host-name R2 level level-2 exit net 49.0001.0100.0000.1002.00 exit
Далее настроим протокол BGP.
Маршрутизатор R5:
router bgp 100 bgp router-id 5.5.5.5 neighbor 2.2.2.2 address-family ipv4 unicast exit remote-as 100 update-source 5.5.5.5 exit neighbor 3.3.3.3 address-family ipv4 unicast exit remote-as 100 update-source 5.5.5.5 exit exit
Маршрутизатор R2:
router bgp 100 address-family ipv4 unicast network 100.0.0.0/30 exit bgp router-id 2.2.2.2 neighbor 100.0.0.1 address-family ipv4 unicast exit remote-as 200 update-source 100.0.0.2 exit neighbor 3.3.3.3 address-family ipv4 unicast exit remote-as 100 update-source 2.2.2.2 exit neighbor 5.5.5.5 address-family ipv4 unicast exit remote-as 100 update-source 2.2.2.2 exit exit
Маршрутизатор R3:
router bgp 100 address-family ipv4 unicast network 100.30.0.0/30 exit bgp router-id 3.3.3.3 neighbor 100.30.0.1 address-family ipv4 unicast exit remote-as 300 update-source 100.30.0.2 exit neighbor 2.2.2.2 address-family ipv4 unicast exit remote-as 100 update-source 3.3.3.3 exit neighbor 5.5.5.5 address-family ipv4 unicast exit remote-as 100 update-source 3.3.3.3 exit exit
Маршрутизатор R1:
router bgp 200 address-family ipv4 unicast network 10.10.0.0/24 exit bgp router-id 1.1.1.1 neighbor 100.0.0.2 address-family ipv4 unicast exit remote-as 100 update-source 100.0.0.1 exit exit
Маршрутизатор R4:
router bgp 300 address-family ipv4 unicast network 10.40.0.0/24 exit bgp router-id 4.4.4.4 neighbor 100.30.0.2 address-family ipv4 unicast exit remote-as 100 update-source 100.30.0.1 exit exit
Настроим анонс маршрута по умолчанию (Default Route) на маршрутизаторах R1 и R4.
Маршрутизатор R1:
router bgp 200 neighbor 100.0.0.2 address-family ipv4 unicast default-originate <============= exit exit exit
Маршрутизатор R4:
router bgp 300 neighbor 100.30.0.2 address-family ipv4 unicast default-originate <=========== exit exit exit
Проверяем таблицу BGP на R5:
0/FMC0:R5# show bgp Fri Dec 20 03:57:51 2024 BGP router identifier 5.5.5.5, local AS number 100 Graceful Restart is disabled BGP table state: active Status codes: d damped, h history, > best, b backup, S stale, * active, u untracked, i internal Origin codes: i igp, e egp, ? incomplete Network Next hop Metric LocPrf Weight Path ------------------------ ---------------- ------- ------- ------- ----- *>i 0.0.0.0/0 100.0.0.1 0 100 0 200 i i 0.0.0.0/0 100.30.0.1 0 100 0 300 i *>i 10.10.0.0/24 100.0.0.1 0 100 0 200 i *>i 10.40.0.0/24 100.30.0.1 0 100 0 300 i *>i 100.0.0.0/30 2.2.2.2 0 100 0 i *>i 100.30.0.0/30 3.3.3.3 0 100 0 i Total entries: 6
А также таблицу маршрутизации.
0/FMC0:R5# show route Fri Dec 20 03:59:11 2024 Codes: C - connected, S - static, O - OSPF, B - BGP, L - local IA - OSPF inter area, EA - OSPF intra area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, LE1 - IS-IS level1 external, LE2 - IS-IS level2 external BI - BGP internal, BE - BGP external, BV - BGP vpn, BL - BGP labeled, R - RIP B BI 0.0.0.0/0 via 100.60.0.2 [200/0], 00h01m27s, te0/0/10.200 i L1 2.2.2.2/32 via 100.60.0.2 [115/10], 01h17m35s, te0/0/10.200 i L1 3.3.3.3/32 via 100.50.0.2 [115/10], 01h17m35s, te0/0/9.200 L 5.5.5.5/32 is directly connected, 01h19m04s, lo0 B BI 10.10.0.0/24 via 100.60.0.2 [200/0], 01h11m23s, te0/0/10.200 B BI 10.40.0.0/24 via 100.50.0.2 [200/0], 00h02m11s, te0/0/9.200 B BI 100.0.0.0/30 via 100.60.0.2 [200/0], 01h15m45s, te0/0/10.200 B BI 100.30.0.0/30 via 100.50.0.2 [200/0], 01h15m46s, te0/0/9.200 C 100.50.0.0/30 is directly connected, 01h17m45s, te0/0/9.200 L 100.50.0.1/32 is directly connected, 01h17m45s, te0/0/9.200 C 100.60.0.0/30 is directly connected, 01h17m45s, te0/0/10.200 L 100.60.0.1/32 is directly connected, 01h17m45s, te0/0/10.200 i L1 100.200.0.0/30 via 100.50.0.2 [115/20], 01h15m42s, te0/0/9.200
Дополнительно настроим фильтрацию маршрутов на R2 и R3:
На R3 настроим route-map, где изменим для маршрута 0.0.0.0/0 параметр weight .
Маршрутизатор R2:
as-path-list as200 seq-num 1 regular-expression ^(200)+$ exit exit prefix-list def seq-num 1 prefix 0.0.0.0/0 exit exit route-map def seq-num 1 match as-path-list as200 match prefix-list destination def set weight value 99 exit seq-num 5 exit exit router bgp 100 neighbor 100.0.0.1 address-family ipv4 unicast route-map in def exit exit exit
На R3 настроим фильтрацию, где принимать будем только маршрут по умолчанию (Default Route):
prefix-list def seq-num 1 prefix 0.0.0.0/0 exit exit router bgp 100 neighbor 100.30.0.1 address-family ipv4 unicast prefix-list in def exit exit exit
Проверяем результат фильтрации на R2:
0/ME5100:R2# show bgp Fri Dec 20 04:22:11 2024 BGP router identifier 2.2.2.2, local AS number 100 Graceful Restart is disabled BGP table state: active Status codes: d damped, h history, > best, b backup, S stale, * active, u untracked, i internal Origin codes: i igp, e egp, ? incomplete Network Next hop Metric LocPrf Weight Path ------------------------ ---------------- ------- ------- ------- ----- i 0.0.0.0/0 100.30.0.1 0 100 0 300 i *> 0.0.0.0/0 100.0.0.1 0 100 99 200 i <=========== *> 10.10.0.0/24 100.0.0.1 0 100 0 200 i > 100.0.0.0/30 0 100 32768 i *>i 100.30.0.0/30 3.3.3.3 0 100 0 i Total entries: 5
Также проверим таблицу BGP на маршрутизаторе R5:
0/FMC0:R5# show bgp Fri Dec 20 04:23:57 2024 BGP router identifier 5.5.5.5, local AS number 100 Graceful Restart is disabled BGP table state: active Status codes: d damped, h history, > best, b backup, S stale, * active, u untracked, i internal Origin codes: i igp, e egp, ? incomplete Network Next hop Metric LocPrf Weight Path ------------------------ ---------------- ------- ------- ------- ----- *>i 0.0.0.0/0 100.0.0.1 0 100 0 200 i i 0.0.0.0/0 100.30.0.1 0 100 0 300 i *>i 10.10.0.0/24 100.0.0.1 0 100 0 200 i *>i 100.0.0.0/30 2.2.2.2 0 100 0 i *>i 100.30.0.0/30 3.3.3.3 0 100 0 i Total entries: 5
Также таблицу маршрутизации на R5:
0/FMC0:R5# show route Fri Dec 20 04:24:08 2024 Codes: C - connected, S - static, O - OSPF, B - BGP, L - local IA - OSPF inter area, EA - OSPF intra area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, LE1 - IS-IS level1 external, LE2 - IS-IS level2 external BI - BGP internal, BE - BGP external, BV - BGP vpn, BL - BGP labeled, R - RIP B BI 0.0.0.0/0 via 100.60.0.2 [200/0], 00h26m25s, te0/0/10.200 i L1 2.2.2.2/32 via 100.60.0.2 [115/10], 01h42m33s, te0/0/10.200 i L1 3.3.3.3/32 via 100.50.0.2 [115/10], 01h42m33s, te0/0/9.200 L 5.5.5.5/32 is directly connected, 01h44m02s, lo0 B BI 10.10.0.0/24 via 100.60.0.2 [200/0], 01h36m21s, te0/0/10.200 B BI 100.0.0.0/30 via 100.60.0.2 [200/0], 01h40m43s, te0/0/10.200 B BI 100.30.0.0/30 via 100.50.0.2 [200/0], 01h40m44s, te0/0/9.200 C 100.50.0.0/30 is directly connected, 01h42m43s, te0/0/9.200 L 100.50.0.1/32 is directly connected, 01h42m43s, te0/0/9.200 C 100.60.0.0/30 is directly connected, 01h42m43s, te0/0/10.200 L 100.60.0.1/32 is directly connected, 01h42m43s, te0/0/10.200 i L1 100.200.0.0/30 via 100.50.0.2 [115/20], 01h40m40s, te0/0/9.200 Total entries: 12