Перейти к основному содержимому

BGP Distance

Административная дистанция в BGP может быть настроена для конкретного адресного семейства.

Топология

Image

Рисунок 7-1: Административная дистанция для IPv4 BGP

SW1

#configure terminalПерейти в режим конфигурации.
(config)#interface loПерейти в режим настройки интерфейса loopback.
(config-if)#ip address 150.1.1.1/24 secondaryУказать IP-адрес для интерфейса.
(config-if)#exitВыйти из режима настройки интерфейса loopback.
(config)#router bgp 100Назначить значение ASN (100) маршрутизатору.
(config-router)#network 150.1.1.0/24Указать сеть, которая будет анонсироваться процессом маршрутизации BGP.
(config-router)#neighbor 1.1.1.2 remote-as 100Указать IP-адрес соседа и значение ASN.

SW2

#configure terminalПерейти в режим конфигурации.
(config)#router bgp 100Назначить значение ASN (100) маршрутизатору.
(config-router)#neighbor 2.2.2.2 remote-as 200Указать IP-адрес соседа и значение ASN.
(config-router)#neighbor 1.1.1.1 remote-as 100Указать IP-адрес соседа и значение ASN другого соседа.
(config-router)#distance bgp 12 13 120Настроить административную дистанцию для внешних, внутренних и локальных маршрутов.
(config-router)#aggregate-address 150.1.0.0/16 summary-onlyНастроить агрегированный маршрут без AS-set на SW2. Локальная дистанция применяется к этому маршруту.

SW3

#configure terminalПерейти в режим конфигурации.
(config)#interface loПерейти в режим настройки интерфейса loopback.
(config-if)#ip address 88.88.1.2/32 secondaryУказать IP-адрес для интерфейса.
(config-if)#exitВыйти из режима настройки интерфейса loopback.
(config)#router bgp 200Назначить значение ASN (200) маршрутизатору.
(config-router)#network 88.88.1.2/32Указать сеть, которая будет анонсироваться процессом маршрутизации BGP.
(config-router)#neighbor 2.2.2.1 remote-as 100Указать IP-адрес соседа и значение ASN.
Проверка

show ip bgp summary, show ip bgp neighbors, show ip route database bgp, show ip route database, show ip route, show ip bgp

#show ip bgp summary
BGP router identifier 192.168.56.102, local AS number 100
BGP table version is 7
2 BGP AS-PATH entries
0 BGP community entries
Neighbor                 V   AS   MsgRcv    MsgSen TblVer   InQ   OutQ    Up/ Down   State/PfxRcd
1.1.1.1                  4   100    8          9       7      0      0  00:02:39               1
2.2.2.2                  4   200    4          4       7      0      0  00:00:38               1
Total number of neighbors 2
Total number of Established sessions 2
#show ip bgp neighbors
BGP neighbor is 1.1.1.1, remote AS 100, local AS 100, internal link
BGP version 4, remote router ID 150.1.1.1   local router ID 192.168.52.3
BGP state = Established, up for 00:02:54
Last read 00:02:54, hold time is 90, keepalive interval is 30 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Received 8 messages, 0 notifications, 0 in queue
Sent 9 messages, 0 notifications, 0 in queue
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 5 seconds
For address family: IPv4 Unicast
BGP table version 7, neighbor version 7
Index 2, Offset 0, Mask 0x4
Community attribute sent to this neighbor (both)
1 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 1.1.1.2, Local port: 49238
Foreign host: 1.1.1.1, Foreign port: 179
Nexthop: 1.1.1.2
Nexthop global: fe80::a00:27ff:fea6:6e3
Nexthop local: ::
BGP connection: non shared network
BGP neighbor is 2.2.2.2, remote AS 200, local AS 100, external link
BGP version 4, remote router ID 88.88.1.2   local router ID 192.168.52.3
BGP state = Established, up for 00:00:53
Last read 00:00:53, hold time is 90, keepalive interval is 30 seconds
Neighbor capabilities:
Route refresh: advertised and received (old and new)
Address family IPv4 Unicast: advertised and received
Received 4 messages, 0 notifications, 0 in queue
Sent 4 messages, 0 notifications, 0 in queue
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 7, neighbor version 7
Index 1, Offset 0, Mask 0x2
Community attribute sent to this neighbor (both)
1 accepted prefixes
0 announced prefixes
Connections established 1; dropped 0
Local host: 2.2.2.1, Local port: 179
Foreign host: 2.2.2.2, Foreign port: 50072
Nexthop: 2.2.2.1
Nexthop global: fe80::a00:27ff:fe77:264e
Nexthop local: ::
BGP connection: non shared network
#show ip route database bgp
IP Route Table for VRF "default"
B    *> 88.88.1.2/32 [12/0] via 2.2.2.2, eth2, 00:01:19
B       *> 150.1.0.0/16 [120/0] is a summary, Null, 00:02:49
B    *> 150.1.1.0/24 [200/0] via 1.1.1.1, eth1, 00:02:49
Gateway of last resort is not set
#show ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
C*>  1.1.1.0/24 is directly connected, eth1, 00:13:39
C    *>  2.2.2.0/24 is directly connected, eth3, 00:13:04
B*>  88.88.1.2/32 [12/0] via 2.2.2.2, eth3, 00:06:37
C*>  127.0.0.0/8 is directly connected, lo, 00:22:15
B    *>  150.1.0.0/16 [120/0] is a summary, Null, 00:11:19
B*>  150.1.1.0/24 [200/0] via 1.1.1.1, eth1, 00:11:19
C*>  192.168.52.0/24 is directly connected, eth0, 00:22:13
Gateway of last resort is not set Gateway of last resort is not set
#show ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked        * - candidate default
IP Route Table for VRF "default"
C     1.1.1.0/24 is directly connected, eth1, 00:17:38
C     2.2.2.0/24 is directly connected, eth3, 00:17:03
B88.88.1.2/32 [12/0] via 2.2.2.2, eth3, 00:10:36
C127.0.0.0/8 is directly connected, lo, 00:26:14
B     150.1.0.0/16 [120/0] is a summary, Null, 00:15:18
B150.1.1.0/24 [200/0] via 1.1.1.1, eth1, 00:15:18
C192.168.52.0/24 is directly connected, eth0, 00:26:12
Gateway of last resort is not set
#show ip bgp
BGP table version is 4, local router ID is 192.168.52.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
l - labeled, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop            Metric    LocPrf       Weight Path
*>   88.88.1.2/32     2.2.2.2              0         100           0       200 i
*>   150.1.0.0        0.0.0.0             0         100           32768    i s
>i  150.1.1.0/24     1.1.1.1              0         100           0        i
Total number of prefixes 3