实验拓扑
实验要求
所有环回可以互相访问
注:R1~R6的环回分别是 1.1.1.1/24~6.6.6.6/24
实验配置
1.首先根据图中给出的网段给每个路由器配置接口IP地址和环回地址(这里不给出具体配置)
2.配置完成后,在R2~R5之间启动OSPF(BGP是以IGP协议为基础,所以先配置OSPF)
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 23.1.1.1 0.0.0.0
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 45.1.1.1 0.0.0.0
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 45.1.1.2 0.0.0.0
配置完成后使用命令 display ospf peer brief 来检查建邻情况,没有问题后进行下一项
3.启动BGP协议
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 2
[R2]bgp 64512
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confe
[R2-bgp]confederation id 2
[R2-bgp]peer 3.3.3.3 as-number 64512
[R2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R2-bgp]peer 12.1.1.1 as-number 1
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]confederation peer-as 64513
[R3-bgp]peer 2.2.2.2 as-number 64512
[R3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R3-bgp]peer 4.4.4.4 as-number 64513
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R3-bgp]peer 4.4.4.4 ebgp-max-hop 2
[R4]bgp 64513
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 2
[R4-bgp]confederation peer-as 64512
[R4-bgp]peer 3.3.3.3 as-number 64512
[R4-bgp]peer 3.3.3.3 connect-interface loopback 0
[R4-bgp]peer 3.3.3.3 ebgp-max-hop 2
[R4-bgp]peer 5.5.5.5 as-number 64513
[R4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R5]bgp 64513
[R5-bgp]router-id 5.5.5.5
[R5-bgp]confederation id 2
[R5-bgp]peer 4.4.4.4 as-number 64513
[R5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
为了防止逻辑悖论,这里用32位环回地址来建邻
[R5]ip route-static 6.6.6.6 32 56.1.1.2
[R5]ip route-static 6.6.6.6 32 65.1.1.2
[R6]ip route-static 5.5.5.5 32 65.1.1.1
[R6]ip route-static 5.5.5.5 32 56.1.1.1
[R5]bgp 64513
[R5-bgp]peer 6.6.6.6 as-number 3
[R5-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[R5-bgp]peer 6.6.6.6 ebgp-max-hop 2
[R6]bgp 3
[R6-bgp]router-id 6.6.6.6
[R6-bgp]peer 5.5.5.5 as-number 2
[R6-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R6-bgp]peer 5.5.5.5 ebgp-max-hop 2
至此全部BGP路由器之间建邻完成
4.配置路由
[R1]bgp 1
[R1-bgp]network 1.1.1.0 24
[R2]bgp 64512
[R2-bgp]peer 3.3.3.3 next-hop-local
[R6]bgp 3
[R6-bgp]network 6.6.6.0 24
[R5]bgp 64513
[R5-bgp]peer 4.4.4.4 next-hop-local
为了防止自身路由器学习到自身环回的32位地址路由,更改环回接口网络类型
[R2]int lo0
[R2-LoopBack0]ospf network-type broadcast
[R3]int lo0
[R3-LoopBack0]ospf network-type broadcast
[R4]int lo0
[R4-LoopBack0]ospf network-type broadcast
[R5]int lo0
[R5-LoopBack0]ospf network-type broadcast
为了让路由均优,在R2,R5上均宣告网段
[R2]bgp 64512
[R2-bgp]network 2.2.2.0 24
[R2-bgp]network 3.3.3.0 24
[R2-bgp]network 4.4.4.0 24
[R2-bgp]network 5.5.5.0 24
[R5]bgp 64513
[R5-bgp]network 2.2.2.0 24
[R5-bgp]network 3.3.3.0 24
[R5-bgp]network 4.4.4.0 24
[R5-bgp]network 5.5.5.0 24
实验配置完成
实验结果