BGP反射器与联邦实验

实验拓扑
BGP反射器与联邦实验_第1张图片
实验配置
首先对于整个AS2区域,对172.16.0.0/16这个网段进行子网划分
172.16.2.0/24
172.16.3.0/24
172.16.4.0/24
172.16.5.0/24
172.16.6.0/24
172.16.7.0/24
172.16.0.0/24
172.16.1.0/24

基础配置
首先是对各个接口进行基础的地址配置
查看各个路由器的地址表
display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.0.0.2/24 up up
GigabitEthernet0/0/1 172.16.1.1/29 up up
GigabitEthernet0/0/2 172.16.1.9/29 up up
LoopBack0 172.16.2.1/24 up up(s)
NULL0 unassigned up up(s)

路由配置
接着在AS2区域中,启用OSPF协议,保证互相之间能够通讯
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
在AS2区域中,其他路由器的配置是一样的

配置完成OSPF之后,查看各个路由器上OSPF路由表
[R3]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
Public routing table : OSPF
Destinations : 9 Routes : 10
OSPF routing table status :
Destinations : 9 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.1.8/29 OSPF 10 2 D 172.16.1.1 GigabitEthernet0/0/0
172.16.1.24/29 OSPF 10 2 D 172.16.1.18 GigabitEthernet0/0/1
172.16.1.32/29 OSPF 10 3 D 172.16.1.1 GigabitEthernet0/0/0
172.16.1.40/29 OSPF 10 3 D 172.16.1.18 GigabitEthernet0/0/1
172.16.2.1/32 OSPF 10 1 D 172.16.1.1 GigabitEthernet0/0/0
172.16.4.1/32 OSPF 10 1 D 172.16.1.18 GigabitEthernet0/0/1
172.16.5.1/32 OSPF 10 2 D 172.16.1.1 GigabitEthernet0/0/0
172.16.6.1/32 OSPF 10 3 D 172.16.1.1 GigabitEthernet0/0/0
OSPF 10 3 D 172.16.1.18 GigabitEthernet0/0/1
172.16.7.1/32 OSPF 10 2 D 172.16.1.18 GigabitEthernet0/0/1
OSPF routing table status :
Destinations : 0 Routes : 0

然后是启动AS之间的BGP协议
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.0.0.2 as-number 2

[R2]bgp 64512 ---- 有联邦存在的时候写联邦AS号
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 2 — 告诉大AS号为2
[R2-bgp]confederation peer-as 64513 — 指定EBGP对等体关系的AS号
[R2-bgp]peer 12.0.0.1 as-number 1
[R2-bgp]peer 172.16.3.1 as-number 64512 — 建立 R2 与 R3 的IGP对等体关系
[R2-bgp]peer 172.16.3.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.5.1 as-number 64513 — 建立 R2 与 R5 的非直连建邻
[R2-bgp]peer 172.16.5.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.5.1 ebgp-max-hop — 将ttl值修改

[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.2.1 as-number 64512
[R3-bgp]peer 172.16.2.1 connect-interface LoopBack 0
[R3-bgp]peer 172.16.4.1 as-number 64512
[R3-bgp]peer 172.16.4.1 connect-interface LoopBack 0

[R4]bgp 64512
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 2
[R4-bgp]confederation peer-as 64513
[R4-bgp]peer 172.16.3.1 as 64512
[R4-bgp]peer 172.16.3.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.7.1 as 64513
[R4-bgp]peer 172.16.7.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.7.1 ebgp-max-hop

[R8]bgp 3
[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 78.0.0.1 as 2

查看一下BGP邻居关系
R2
[R2]display bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 64512
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
12.0.0.1 4 1 19 19 0 00:17:28 Established 0
172.16.3.1 4 64512 14 16 0 00:12:21 Established 0
172.16.5.1 4 64513 8 10 0 00:06:11 Established 0
R3
[R3]display bgp peer
BGP local router ID : 3.3.3.3
Local AS number : 64512
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
172.16.2.1 4 64512 14 14 0 00:12:49 Established 0
172.16.4.1 4 64512 11 14 0 00:09:49 Established 0

发布R1路由
[R1-bgp]network 10.0.0.0 24
[R1-bgp]display bgp peer

查看BGP路由表
[R1-bgp]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: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.0.0.0/24 0.0.0.0 0 0 i

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/Og
*> 10.0.0.0/24 12.0.0.1 0 0 1i

注意这边需要修改下一跳,来解决R3,R5可以收到路由,但是不能使用路由,传递给后面的路由器这一个问题
[R2]bgp 64512
[R2-bgp]peer 172.16.3.1 next-hop-local
[R2-bgp]peer 172.16.5.1 next-hop-local

此时会遇到IBGP的水平分割的问题,那么这边可以设置路由反射器来解决以上问题
R3作为RR,反射指定R2作为客户
[R3]bgp 64512
[R3-bgp]peer 172.16.2.1 reflect-client — 指定R2作为客户
同理R6作为RR,反射指定R7或R5作为客户

发布R8路由
[R8]bgp 3
[R8-bgp]network 11.0.0.0 24

因为下一跳的地址为78.0.0.2 所以R4与R6收不到路由信息,解决办法:修改为本地路由信息

AS2内部环回路由信息互相访问
先进行路由聚合
配置空接口,再进行静态路由的发布
[R1]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
*> 10.0.0.0/24 0.0.0.0 0 0 i
*> 11.0.0.0/24 12.0.0.2 0 2 3i
*> 172.16.0.0/21 12.0.0.2 0 0 2i
此时整个网络所有设备的环回都可以互相访问
但是,如果R8发送172.16.0.1(路由黑洞)发送给R7,最终被R2丢掉会使得黑洞在AS2内部占用从而浪费资源
那么解决方法是配置一个空接口
[R7]ip route-static 172.16.0.0 21 NULL 0
[R7]bgp 64513
[R7-bgp]network 172.16.0.0 21

同时为了解决环回地址192.168.2.0 /24不能在任何协议中宣告,可以使用制作GRE隧道的方法
首先制作GRE隧道
[R1]int t 0/0/0
[R1-Tunnel0/0/0]ip address 99.0.0.1 24 ---- 配置网段
[R1-Tunnel0/0/0]tunnel-protocol gre — 定义隧道的封装类型
[R1-Tunnel0/0/0]source 10.0.0.1 —定义封装内容
[R1-Tunnel0/0/0]destination 11.0.0.1

[R8]int t 0/0/0
[R8-Tunnel0/0/0]ip address 99.0.0.2 24
[R8-Tunnel0/0/0]tunnel-protocol gre
[R8-Tunnel0/0/0]source 11.0.0.1
[R8-Tunnel0/0/0]destination 10.0.0.1

配置静态路由
[R1]ip route-static 192.168.2.0 24 99.0.0.2

[R8]ip route-static 192.168.1.0 24 99.0.0.1

测试结果,能够ping通
[R8]ping -a 192.168.2.1 192.168.1.1
PING 192.168.1.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.1: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 192.168.1.1: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 192.168.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 192.168.1.1: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 192.168.1.1: bytes=56 Sequence=5 ttl=255 time=30 ms
— 192.168.1.1 ping statistics —
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/44/60 ms

你可能感兴趣的:(智能路由器,网络)