一、组网需求
1、如图所示,用户将网络划分为AS65008和AS65009,在AS65009内,使用IGP协议来计算路由(该例使用OSPF做为IGP协议)。要求实现两个AS之间的互相通信。
2、网络拓扑
3、配置思路
采用如下的思路配置BGP与IGP交互:
在RouterB和RouterC上配置OSPF协议,使RouterB和RouterC之间可以互访。
在RouterA和RouterB上配置EBGP连接,使RouterA和RouterB之间可以通过BGP相互传递路由。
在RouterB上配置BGP与OSPF互相引入,实现两个AS之间的互相通信。
(可选)在RouterB上配置BGP路由聚合,可以简化BGP路由表规模。
二、操作步骤
1、配置各接口IP地址
system-view
[Huawei]sysname RouterA
[RouterA]interface GigabitEthernet 0/0/0
[RouterA-GigabitEthernet0/0/0]ip address 8.1.1.254 24
[RouterA-GigabitEthernet0/0/0]q
[RouterA]interface GigabitEthernet 0/0/1
[RouterA-GigabitEthernet0/0/1]ip address 3.1.1.2 24
[RouterA-GigabitEthernet0/0/1]q
system-view
[Huawei]sysname RouterB
[RouterB]interface GigabitEthernet 0/0/1
[RouterB-GigabitEthernet0/0/1]ip address 3.1.1.1 24
[RouterB-GigabitEthernet0/0/1]q
[RouterB]interface GigabitEthernet 0/0/2
[RouterB-GigabitEthernet0/0/2]ip address 9.1.1.1 24
[RouterB-GigabitEthernet0/0/2]q
system-view
[Huawei]sysname RouterC
[RouterC]interface GigabitEthernet 0/0/2
[RouterC-GigabitEthernet0/0/2]ip address 9.1.1.2 24
[RouterC-GigabitEthernet0/0/2]q
[RouterC]interface GigabitEthernet 0/0/0
[RouterC-GigabitEthernet0/0/0]ip address 9.1.2.254 24
[RouterC-GigabitEthernet0/0/0]q
2、配置AS65009的OSPF
[RouterB]ospf 1 router-id 2.2.2.2
[RouterB-ospf-1]area 0
[RouterB-ospf-1-area-0.0.0.0]network 9.1.1.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]q
[RouterB-ospf-1]q
[RouterC]ospf 1 router-id 3.3.3.3
[RouterC-ospf-1]area 0
[RouterC-ospf-1-area-0.0.0.0]network 9.1.1.0 0.0.0.255
[RouterC-ospf-1-area-0.0.0.0]network 9.1.2.0 0.0.0.255
[RouterC-ospf-1-area-0.0.0.0]q
[RouterC-ospf-1]q
3、配置EBGP连接
[RouterA]bgp 65008
[RouterA-bgp]router-id 1.1.1.1
[RouterA-bgp]peer 3.1.1.1 as-number 65009
[RouterA-bgp]ipv4-family unicast
[RouterA-bgp-af-ipv4]network 8.1.1.0 24
[RouterA-bgp-af-ipv4]q
[RouterA-bgp]q
[RouterB]bgp 65009
[RouterB-bgp]router-id 2.2.2.2
[RouterB-bgp]peer 3.1.1.2 as-number 65008
[RouterB-bgp]q
4、配置BGP和IGP交互,在RouterB上配置BGP引入OSPF路由,配置OSPF引入BGP路由
[RouterB]bgp 65009
[RouterB-bgp]ipv4-family unicast
[RouterB-bgp-af-ipv4]import-route ospf 1
[RouterB-bgp-af-ipv4]q
[RouterB-bgp]q
查看RouterA是否学习到路由
[RouterA]display 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: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 8.1.1.0/24 0.0.0.0 0 0 i
*> 9.1.1.0/24 3.1.1.1 0 0 65009?
*> 9.1.2.0/24 3.1.1.1 2 0 65009?
[RouterB]ospf 1
[RouterB-ospf-1]import-route bgp
[RouterB-ospf-1]q
5、RouterC查看路由表
[RouterC]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.1.1.0/24 O_ASE 150 1 D 9.1.1.1 GigabitEthernet
0/0/2
9.1.1.0/24 Direct 0 0 D 9.1.1.2 GigabitEthernet
0/0/2
9.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
9.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
9.1.2.0/24 Direct 0 0 D 9.1.2.254 GigabitEthernet
0/0/0
9.1.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
9.1.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
6、配置路由自动聚合
[RouterB]bgp 65009
[RouterB-bgp]ipv4-family unicast
[RouterB-bgp-af-ipv4]summary automatic
[RouterB-bgp-af-ipv4]q
7、RouterA查看BGP路由表
[RouterA]display 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: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 8.1.1.0/24 0.0.0.0 0 0 i
*> 9.0.0.0 3.1.1.1 0 65009?
8、ping验证
[RouterA]ping -a 8.1.1.254 9.1.2.1
PING 9.1.2.1: 56 data bytes, press CTRL_C to break
Request time out
Reply from 9.1.2.1: bytes=56 Sequence=2 ttl=126 time=30 ms
Reply from 9.1.2.1: bytes=56 Sequence=3 ttl=126 time=30 ms
Reply from 9.1.2.1: bytes=56 Sequence=4 ttl=126 time=20 ms
Reply from 9.1.2.1: bytes=56 Sequence=5 ttl=126 time=30 ms
--- 9.1.2.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 20/27/30 ms