学习精彩网络技术老师:华为HCIA和HCIP数通eNSP实战视频课、华三、锐捷、WLAN、IPv6等全套视频课程
配置BGP和IGP的交互,可以丰富协议路由表。
组网需求
通信业务的发展,要求能够在广泛的区域实现互访,并且数据传输可靠,中断时间短,这就要求路由的传播区域广,收敛速度快。BGP可以实现路由的高效广泛传播,但是BGP自身不会计算路由。IGP可以实现路由的快速收敛,但是IGP的路由传播效率低,范围小。配置BGP与IGP交互后,IGP路由可以被引入到BGP路由表进行高效广泛的传播,BGP路由也可以被引入到IGP路由表,实现对其他AS的访问。
如图1所示,用户将网络划分为AS65008和AS65009,在AS65009内,使用IGP协议来计算路由(该例使用OSPF做为IGP协议)。为了实现两个AS之间的互访,可以在AS之间配置BGP协议,在AS边缘NE上配置BGP与IGP交互,这样既可以利用BGP高效的把路由传递到其他AS,也可以把AS外部的路由引入到IGP,实现对AS外部的访问。
本例中interface1,interface2分别代表GE0/1/0,GE0/2/0。
配置思路
采用如下的思路配置BGP与IGP交互:
在DeviceB和DeviceC上配置OSPF协议。
在DeviceA和DeviceB上配置EBGP连接。
在DeviceB上配置BGP与OSPF互相引入,查看路由信息。
在DeviceB上配置BGP路由聚合,简化BGP路由表。
数据准备
为完成此配置例,需准备如下的数据:
DeviceA的Router ID以及所在AS号。
DeviceB、DeviceC的Router ID以及所在AS号。
操作步骤
- 配置各接口的IP地址(略)
- 配置OSPF
# 配置DeviceB。
[~DeviceB] ospf 1
[*DeviceB-ospf-1] area 0
[*DeviceB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] commit
[~DeviceB-ospf-1-area-0.0.0.0] quit
[~DeviceB-ospf-1] quit
# 配置DeviceC。
[~DeviceC] ospf 1
[*DeviceC-ospf-1] area 0
[*DeviceC-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[*DeviceC-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255
[*DeviceC-ospf-1-area-0.0.0.0] commit
[~DeviceC-ospf-1-area-0.0.0.0] quit
[~DeviceC-ospf-1] quit
- 配置EBGP连接
# 配置DeviceA。
[~DeviceA] bgp 65008
[*DeviceA-bgp] router-id 1.1.1.1
[*DeviceA-bgp] peer 172.16.1.1 as-number 65009
[*DeviceA-bgp] ipv4-family unicast
[*DeviceA-bgp-af-ipv4] network 192.168.1.0 255.255.255.0
[*DeviceA-bgp-af-ipv4] commit
# 配置DeviceB。
[~DeviceB] bgp 65009
[*DeviceB-bgp] router-id 2.2.2.2
[*DeviceB-bgp] peer 172.16.1.2 as-number 65008
[*DeviceB-bgp] commit
- 配置BGP与IGP交互
# 在DeviceB上配置BGP引入OSPF路由。
[~DeviceB-bgp] ipv4-family unicast
[*DeviceB-bgp-af-ipv4] import-route ospf 1
[*DeviceB-bgp-af-ipv4] commit
[~DeviceB-bgp-af-ipv4] quit
[~DeviceB-bgp] quit
# 查看DeviceA的路由表。
[~DeviceA] display bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped, x - best external, a - add path,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V - valid, I - invalid, N - not-found
Total Number of Routes: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 192.168.1.0/24 0.0.0.0 0 0 i
*> 10.1.1.0/24 172.16.1.1 1 0 65009?
*> 10.1.2.0/24 172.16.1.1 2 0 65009?
# 在DeviceB上配置OSPF引入BGP路由。
[~DeviceB] ospf
[*DeviceB-ospf-1] import-route bgp
[*DeviceB-ospf-1] commit
[~DeviceB-ospf-1] quit
# 显示DeviceC的路由表。
[~DeviceC] display ip routing-tableRoute Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Table : _public_
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 O_ASE 150 1 D 10.1.1.1 GigabitEthernet0/1/0
10.1.1.0/24 Direct 0 0 D 10.1.1.2 GigabitEthernet0/1/0
10.1.1.1/32 Direct 0 0 D 10.1.1.1 GigabitEthernet0/1/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/1/0
10.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/1/0
10.1.2.0/24 Direct 0 0 D 10.1.2.1 GigabitEthernet0/2/0
10.1.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/2/0
10.1.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/2/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
- 配置路由自动聚合
# 配置DeviceB。
[~DeviceB] bgp 65009
[*DeviceB-bgp] ipv4-family unicast
[*DeviceB-bgp-af-ipv4] summary automatic
[*DeviceB-bgp-af-ipv4] commit
# 显示DeviceA的BGP路由表。
[~DeviceA] display bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped, x - best external, a - add path,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V - valid, I - invalid, N - not-found
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 192.168.1.0/24 0.0.0.0 0 0 i
*> 10.0.0.0 172.16.1.1 0 65009?
# 使用ping命令进行验证。
[~DeviceA] ping -a 192.168.1.1 10.1.2.1
PING 10.1.2.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.2.1: bytes=56 Sequence=1 ttl=254 time=15 ms
Reply from 10.1.2.1: bytes=56 Sequence=2 ttl=254 time=31 ms
Reply from 10.1.2.1: bytes=56 Sequence=3 ttl=254 time=47 ms
Reply from 10.1.2.1: bytes=56 Sequence=4 ttl=254 time=46 ms
Reply from 10.1.2.1: bytes=56 Sequence=5 ttl=254 time=47 ms
--- 10.1.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/37/47 ms
配置文件
DeviceA的配置文件
#
sysname DeviceA
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.16.1.2 255.255.255.0
#
bgp 65008
router-id 1.1.1.1
peer 172.16.1.1 as-number 65009
#
ipv4-family unicast
undo synchronization
network 192.168.1.0 255.255.255.0
peer 172.16.1.1 enable
#
return
DeviceB的配置文件
#
sysname DeviceB
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 10.1.1.1 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.16.1.1 255.255.255.0
#
bgp 65009
router-id 2.2.2.2
peer 172.16.1.2 as-number 65008
#
ipv4-family unicast
undo synchronization
summary automatic
import-route ospf 1
peer 172.16.1.2 enable
#
ospf 1
import-route bgp
area 0.0.0.0
network 10.1.1.0 0.0.0.255
#
return
DeviceC的配置文件
#
sysname DeviceC
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 10.1.1.2 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 10.1.2.1 255.255.255.0
#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 10.1.2.0 0.0.0.255
#
return