组网需求
如图所示,用户将网络划分为AS65008和AS65009,在AS65009内,使用IGP协议来计算路由(该例使用OSPF做为IGP协议)。要求实现两个AS之间的互相通信。
配置思路
采用如下的思路配置BGP与IGP交互:
- 在AR2、AR3和AR4上配置OSPF协议,使AR2、AR3和AR4之间可以互访。
- 在AR1和AR2上配置EBGP连接,使AR1和AR2之间可以通过BGP相互传递路由。
- 在AR2上配置BGP与OSPF互相引入,实现两个AS之间的互相通信。
- 在AR2上配置BGP路由聚合,可以简化BGP路由表规模。
操作步骤
配置IP
AR1
powershell
<Huawei>sys
[Huawei]sys AR1
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 12.12.12.1 24
[AR1-GigabitEthernet0/0/0]q
[AR1]int lo1
[AR1-LoopBack1]ip add 1.1.1.1 24
[AR1-LoopBack1]q
AR2
powershell
<Huawei>sys
[Huawei]sys AR2
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 12.12.12.2 24
[AR2-GigabitEthernet0/0/0]q
[AR2]int g0/0/1
[AR2-GigabitEthernet0/0/1]ip add 10.10.23.2 24
[AR2-GigabitEthernet0/0/1]q
AR3
powershell
<Huawei>sys
[Huawei]sys AR3
[AR3]int g0/0/0
[AR3-GigabitEthernet0/0/0]ip add 10.10.23.3 24
[AR3-GigabitEthernet0/0/0]q
[AR3]int g0/0/1
[AR3-GigabitEthernet0/0/1]ip add 10.10.34.3 24
[AR3-GigabitEthernet0/0/1]q
[AR3]
AR4
powershell
<Huawei>sys
[Huawei]sys AR4
[AR4]int g0/0/0
[AR4-GigabitEthernet0/0/0]ip add 10.10.34.4 24
[AR4-GigabitEthernet0/0/0]q
配置OSPF
AR2
powershell
[AR2]ospf
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]network 10.10.23.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]q
AR3
powershell
[AR3]ospf
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 10.10.23.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]network 10.10.34.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]q
AR4
powershell
[AR4]ospf
[AR4-ospf-1]area 0
[AR4-ospf-1-area-0.0.0.0]network 10.10.34.0 0.0.0.255
[AR4-ospf-1-area-0.0.0.0]q
在AR4上查看OSPF路由表
powershell
[AR4-ospf-1]display ospf routing
OSPF Process 1 with Router ID 10.10.34.4
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.10.34.0/24 1 Transit 10.10.34.4 10.10.34.4 0.0.0.0
10.10.23.0/24 2 Transit 10.10.34.3 12.12.12.2 0.0.0.0
Total Nets: 2
Intra Area: 2 Inter Area: 0 ASE: 0 NSSA: 0
配置BGP
AR1
powershell
[AR1]bgp 65008
[AR1-bgp]router-id 1.1.1.1
[AR1-bgp] peer 12.12.12.2 as-number 65009
# 单播发布路由
[AR1-bgp] ipv4-family unicast
[AR1-bgp-af-ipv4]network 1.1.1.0 255.255.255.0
AR2
powershell
[AR2]bgp 65008
[AR2-bgp]router-id 2.2.2.2
[AR2-bgp] peer 12.12.12.1 as-number 65009
在AR2上查看BGP路由表
powershell
[AR2-bgp]display 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
*> 1.1.1.0/24 12.12.12.1 0 0 65008i
[AR2-bgp]
配置路由引入
BGP路由引入到OSPF
AR2
powershell
[AR2]ospf
[AR2-ospf-1]import-route bgp
[AR2-ospf-1]q
再次在AR4上查看OSPF路由表
powershell
<AR4>display ospf routing
OSPF Process 1 with Router ID 10.10.34.4
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.10.34.0/24 1 Transit 10.10.34.4 10.10.34.4 0.0.0.0
10.10.23.0/24 2 Transit 10.10.34.3 12.12.12.2 0.0.0.0
Routing for ASEs
Destination Cost Type Tag NextHop AdvRouter
1.1.1.0/24 1 Type2 1 10.10.34.3 12.12.12.2
Total Nets: 3
Intra Area: 2 Inter Area: 0 ASE: 1 NSSA: 0
<AR4>
OSPF路由引入到BGP
AR2
powershell
[AR2]bgp 65009
[AR2-bgp]ipv4-family unicast
[AR2-bgp-af-ipv4]import-route ospf 1
[AR2-bgp-af-ipv4]q
再次在AR1上查看BGP路由表
powershell
<AR1>display bgp routing-table
BGP Local router ID is 12.12.12.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: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.0/24 0.0.0.0 0 0 i
*> 10.10.23.0/24 12.12.12.2 0 0 65009?
*> 10.10.34.0/24 12.12.12.2 2 0 65009?
验证AS之间互通
AR4 ping AR1的LoopBack1
powershell
<AR4>ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=253 time=60 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=253 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=253 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=253 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=253 time=40 ms
--- 1.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/42/60 ms
#能ping即AS之间已互通
配置自动路由聚合
AR2
powershell
[AR2]bgp 65009
[AR2-bgp]ipv4-family unicast
[AR2-bgp-af-ipv4]summary automatic
AR1上查看路由表
powershell
<AR1>display bgp routing-table
BGP Local router ID is 12.12.12.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: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.0/24 0.0.0.0 0 0 i
*> 10.0.0.0 12.12.12.2 0 65009?
<AR1>
聚合后再次验证互通
在AR1使用LoopBack1 ping AR4
powershell
<AR1>ping -a 1.1.1.1 10.10.34.4
PING 10.10.34.4: 56 data bytes, press CTRL_C to break
Reply from 10.10.34.4: bytes=56 Sequence=1 ttl=253 time=30 ms
Reply from 10.10.34.4: bytes=56 Sequence=2 ttl=253 time=50 ms
Reply from 10.10.34.4: bytes=56 Sequence=3 ttl=253 time=40 ms
Reply from 10.10.34.4: bytes=56 Sequence=4 ttl=253 time=10 ms
Reply from 10.10.34.4: bytes=56 Sequence=5 ttl=253 time=40 ms
--- 10.10.34.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/34/50 ms
<AR1>