【组网拓扑】
R5、R1、R2、R4之间如下方式连接起来,各接口ip如图所示,AS100内运行RIPv2协议,AS200内运行OSPF协议,AS100和AS200内运行BGP协议
本文实验采用的交换机是H3C模拟器,下载地址如下:http://forum.h3c.com/forum.php?mod=viewthread&tid=109740&highlight=H3C%E6%A8%A1%E6%8B%9F%E5%99%A8
有兴趣的朋友可以在论坛上去下载。
【配置步骤】
先将接口IP以及RIP ospf相关的配置完成,见文章最后各路由器的配置文本
【BGP的相关配置】
注:模拟器的配置命令与实际的有区别,但影响不大,比如 peer 10.1.3.1 group ex as-number 100 在模拟器上显示出来后是两条使命,输入时仍然是一条命令。
[R1-bgp]dis th
#
bgp 100
import-route direct
import-route rip 1
undo synchronization
peer 10.1.3.2 as-number 200
group ex external
peer 10.1.3.2 group ex
bgp 200
import-route direct
import-route ospf 1
undo synchronization
peer 10.1.3.1 as-number 100
group ex external
peer 10.1.3.1 group ex
配置完成后,R1和R2学到了整个全网的路由:
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.1/32 RIP 100 1 10.1.2.1 S0/6/3
10.1.2.0/24 Direct 0 0 10.1.2.2 S0/6/3
10.1.2.1/32 Direct 0 0 10.1.2.1 S0/6/3
10.1.2.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.3.0/24 Direct 0 0 10.1.3.1 S0/6/0
10.1.3.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.3.2/32 Direct 0 0 10.1.3.2 S0/6/0
10.1.4.0/24 BGP 255 0 10.1.3.2 S0/6/0
10.1.4.2/32 BGP 255 0 10.1.3.2 S0/6/0
10.1.5.1/32 BGP 255 1562 10.1.3.2 S0/6/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
[R2] dis ip ro
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.1/32 BGP 255 1 10.1.3.1 S0/6/0
10.1.2.0/24 BGP 255 0 10.1.3.1 S0/6/0
10.1.2.1/32 BGP 255 0 10.1.3.1 S0/6/0
10.1.3.0/24 Direct 0 0 10.1.3.2 S0/6/0
10.1.3.1/32 Direct 0 0 10.1.3.1 S0/6/0
10.1.3.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.4.0/24 Direct 0 0 10.1.4.1 S0/6/1
10.1.4.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.4.2/32 Direct 0 0 10.1.4.2 S0/6/1
10.1.5.1/32 OSPF 10 1562 10.1.4.2 S0/6/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
【R4和R5可以学到全网的路由】
为什么R5和R4没有学到全网的路由呢,这是因为将OSPF RIP学习到的路由引入到了BGP,但是BPG路由并没有宣告给RIP及OSPF协议,的以导致R4和R5没有学习到全网路由,而将BGP路由引入到IGP并不是最好的办法,因为BGP路由在实际应用中会非常地庞大,会导致IGP路由表压力过大,影响设备的性能。
如何解决这个问题呢?
其实OSPF有一个好的解决方法,就是可以向内部区域发布一条缺省的路由(具体的几种情况请见OSPF缺省路由引入的那篇文章),而在RIP中,可以手工写一条缺省路由来实现。
分别在R2和R5上作如下配置
[R2-ospf-1]dis th
#
ospf 1
default-route-advertise always
area 0.0.0.0
network 10.1.4.0 0.0.0.255
#
[R5]ip route-static 0.0.0.0 0.0.0.0 10.1.2.2
验证:
[R5]dis ip ro
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 Static 60 0 10.1.2.2 S0/6/3
10.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.2.0/24 Direct 0 0 10.1.2.1 S0/6/3
10.1.2.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.2.2/32 Direct 0 0 10.1.2.2 S0/6/3
10.1.3.0/24 RIP 100 1 10.1.2.2 S0/6/3
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
[R5]ping 10.1.5.1
PING 10.1.5.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.5.1: bytes=56 Sequence=1 ttl=253 time=4 ms
Reply from 10.1.5.1: bytes=56 Sequence=2 ttl=253 time=10 ms
Request time out
Reply from 10.1.5.1: bytes=56 Sequence=4 ttl=253 time=10 ms
Reply from 10.1.5.1: bytes=56 Sequence=5 ttl=253 time=1 ms
--- 10.1.5.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 1/6/10 ms
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_ASE 150 1 10.1.4.1 S0/6/1
10.1.4.0/24 Direct 0 0 10.1.4.2 S0/6/1
10.1.4.1/32 Direct 0 0 10.1.4.1 S0/6/1
10.1.4.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.5.1/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_ASE 150 1 10.1.4.1 S0/6/1
10.1.4.0/24 Direct 0 0 10.1.4.2 S0/6/1
10.1.4.1/32 Direct 0 0 10.1.4.1 S0/6/1
10.1.4.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.5.1/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
PING 10.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=253 time=20 ms
Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=253 time=1 ms
Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=253 time=1 ms
Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=253 time=10 ms
Request time out
--- 10.1.1.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 1/8/20 ms
R5可以PING 通10.1.5.1 ,R4可以ping 通10.1.1.1 结果表明R5和R4之间的路由是通的。
【配置文本】