BGP协议基本配置
边界网关协议BGP实现自治系统AS的路由可达EBGP:运行于不同 AS 之间的 BGP 称为 EBGP。为了防止 AS 间产生环路,当 BGP 设备接收 EBGP对等体发送的路由时,会将带有本地 AS 号的路由丢弃。IBGP:运行于同一 AS 内部的 BGP 称为 IBGP。为了防止 AS 内产生环路, BGP 设备不将从 IBGP 对等体学到的路由通告给其他 IBGP 对等体缺省需要与所有 IB
边界网关协议BGP实现自治系统AS的路由可达
EBGP:运行于不同 AS 之间的 BGP 称为 EBGP。为了防止 AS 间产生环路,当 BGP 设备接收 EBGP对等体发送的路由时,会将带有本地 AS 号的路由丢弃。
IBGP:运行于同一 AS 内部的 BGP 称为 IBGP。为了防止 AS 内产生环路, BGP 设备不将从 IBGP 对等体学到的路由通告给其他 IBGP 对等体缺省需要与所有 IBGP对等体建立全连接才能实现 AS 内部各 IBGP 设备间的路由互通。
使用BGP在AS内转发路由条目时,要保证本AS内的IGP路由表已经有这条路由
网络拓扑图:
按照拓扑图配置路由器接口IP地址:
以R2为例子配置:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 59.74.112.1 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 172.16.30.1 24
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 172.16.10.1 24
[R2-GigabitEthernet0/0/2]quit
[R2]
R1、R3、R4同理
在 Router2、Router3 和 RouterD4间配置 IBGP 连接。
[R2]bgp 65009
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 172.16.30.2 as-number 65009
[R2-bgp]peer 172.16.10.2 as-number 65009
[R3]bgp 65009
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 172.16.30.1 as-number 65009
[R3-bgp]peer 172.16.20.2 as-number 65009
[R3-bgp]quit
[R4]bgp 65009
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 172.16.10.1 as-number 65009
[R4-bgp]peer 172.16.20.1 as-number 65009
[R4-bgp]quit
[R4]
在 Router1 和 Router2 之间配置 EBGP 连接。
配置R1:
[R1]bgp 65008
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 59.74.112.1 as-number 65009
配置R2:
[R2-bgp]peer 59.74.112.2 as-number 65008
显示R2的BGP配置结果:
[R2-bgp]dis bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 65009
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
59.74.112.2 4 65008 3 3 0 00:01:06 Established
0
172.16.10.2 4 65009 5 6 0 00:03:31 Established
0
172.16.30.2 4 65009 6 7 0 00:04:35 Established
0
[R2-bgp]
测试BGP协议:
配置R1发布路由172.16.60.0/24并查看路由表信息
[R1-bgp]ipv4-family unicast
[R1-bgp-af-ipv4]net 172.16.60.0 24
[R1-bgp-af-ipv4]quit
[R1-bgp]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 172.16.60.0/24 0.0.0.0 0 0 i
[R1-bgp]
并查看R2的路由表有没有更新:
[R2-bgp]dis bgp routing-table
BGP Local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 172.16.60.0/24 59.74.112.2 0 0 65008i
[R2-bgp]
而且发现AS65009内的所有路由器都已经收到这一条路由更新:
[R3]bgp 65009
[R3-bgp]dis bgp routing-table
BGP Local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
i 172.16.60.0/24 59.74.112.2 0 100 0 65008i
[R3-bgp]
[R4]bgp 65009
[R4-bgp]dis bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
i 172.16.60.0/24 59.74.112.2 0 100 0 65008i
[R4-bgp]
R3和R4 虽然学到了 AS65008 中的 172.16.60.0/24 的路由,但因为下一跳 59.74.112.2 不可达,所以不是有效路由。
所以配置BGP引入直连路由
配置AS边界路由器R2
[R2-bgp]ipv4-family unicast
[R2-bgp-af-ipv4]import-route direct
此时查看R1的路由表发现更新了到达AS 65009各个路由器的路径:
[R1-bgp]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 172.16.60.0/24 0.0.0.0 0 0 i
[R1-bgp]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
59.74.112.0/24 59.74.112.1 0 0 65009?
*> 172.16.10.0/24 59.74.112.1 0 0 65009?
*> 172.16.30.0/24 59.74.112.1 0 0 65009?
*> 172.16.60.0/24 0.0.0.0 0 0 i
[R1-bgp]
查看R3、R4的BGP路由表也是一样的结果
更多推荐
所有评论(0)