BGP综合小实验
题目及IP规划
配置各个路由之间的环回
R1
[R1]int loop0
[R1-LoopBack0]ip add 1.1.1.1 24
R2-R7这几个路由lop0适用于建邻的,lop1是用户
R2
[R2]int loop0
[R2-LoopBack0]ip add 172.16.1.2 32
[R2-LoopBack0]int loop1
[R2-LoopBack1]ip add 172.16.2.1 24
R3
[R3]int loop0
[R3-LoopBack0]ip add 172.16.1.3 32
[R3-LoopBack0]int loop1
[R3-LoopBack1]ip add 172.16.3.1 24
R4
[R4]int loop0
[R4-LoopBack0]ip add 172.16.1.4 32
[R4-LoopBack0]int loop1
[R4-LoopBack1]ip add 172.16.4.1 24
R5
[R5]int loop0
[R5-LoopBack0]ip add 172.16.1.5 32
[R5-LoopBack0]int loop1
[R5-LoopBack1]ip add 172.16.5.1 24
R6
[R6]int loop0
[R6-LoopBack0]ip add 172.16.1.6 32
[R6-LoopBack0]int loop1
[R6-LoopBack1]ip add 172.16.6.1 24
R7
[R7]int loop0
[R7-LoopBack0]ip add 172.16.1.7 32
[R7-LoopBack0]int loop1
[R7-LoopBack1]ip add 172.16.7.1 24
R8
[R8]int loop0
[R8-LoopBack0]ip add 8.8.8.8 24
配置AS2中的OSPF协议
R2
[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.255.255
R3
[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
R3
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R4
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R5
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R6
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R7
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
修改接口的工作方式模拟成真正用户网段的效果
首先查看R2的路由
R2
[R2]int loop1
[R2-LoopBack1]ospf network-type broadcast
R3
[R3]int loop1
[R3-LoopBack1]ospf network-type broadcast
R4
[R4]int loop1
[R4-LoopBack1]ospf network-type broadcast
R5
[R5]int loop1
[R5-LoopBack1]ospf network-type broadcast
R6
[R6]int loop1
[R6-LoopBack1]ospf network-type broadcast
R3
[R7]int loop1
[R7-LoopBack1]ospf network-type broadcast
再次查看R2路由情况
配置BGP
BGP建邻
R1
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 2
R2
[R2]bgp 64512
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 2
[R2-bgp]confederation peer-as 64513
[R2-bgp]peer 12.1.1.1 as-number 1
[R2-bgp]peer 172.16.1.3 as-number 64512
[R2-bgp]peer 172.16.1.3 connect-interface LoopBack 0 (修改更新源)
[R2-bgp]peer 172.16.1.5 as-number 64513
[R2-bgp]peer 172.16.1.5 connect-interface LoopBack 0 (修改更新源)
[R2-bgp]peer 172.16.1.5 ebgp-max-hop 2 (由于R2和R5之间建立的是联邦类的EBGP所以要修改跳数)
R3
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.1.2 as-number 64512
[R3-bgp]peer 172.16.1.2 connect-interface LoopBack 0
[R3-bgp]peer 172.16.1.4 as-number 64512
[R3-bgp]peer 172.16.1.4 connect-interface LoopBack 0
R4
[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.1.3 as-number 64512
[R4-bgp]peer 172.16.1.3 connect-interface LoopBack 0
[R4-bgp]peer 172.16.1.7 as-number 64513
[R4-bgp]peer 172.16.1.7 connect-interface LoopBack 0
[R4-bgp]peer 172.16.1.7 ebgp-max-hop 2
R5
[R5]bgp 64513
[R5-bgp]router-id 5.5.5.5
[R5-bgp]confederation id 2
[R5-bgp]confederation peer-as 64512
[R5-bgp]peer 172.16.1.2 as-number 64512
[R5-bgp]peer 172.16.1.2 connect-interface LoopBack 0
[R5-bgp]peer 172.16.1.2 ebgp-max-hop 2
[R5-bgp]peer 172.16.1.6 as-number 64513
[R5-bgp]peer 172.16.1.6 connect-interface LoopBack 0
R6
[R6]bgp 64513
[R6-bgp]router-id 6.6.6.6
[R6-bgp]confederation id 2
[R6-bgp]peer 172.16.1.5 as-number 64513
[R6-bgp]peer 172.16.1.5 connect-interface LoopBack 0
[R6-bgp]peer 172.16.1.7 as-number 64513
[R6-bgp]peer 172.16.1.7 connect-interface LoopBack 0
R7
[R7]bgp 64513
[R7-bgp]router-id 7.7.7.7
[R7-bgp]confederation id 2
[R7-bgp]confederation peer-as 64512
[R7-bgp]peer 172.16.1.4 as-number 64512
[R7-bgp]peer 172.16.1.4 connect-interface LoopBack 0
[R7-bgp]peer 172.16.1.4 ebgp-max-hop 2
[R7-bgp]peer 172.16.1.6 as-number 64513
[R7-bgp]peer 172.16.1.6 connect-interface LoopBack 0
[R7-bgp]peer 78.1.1.2 as-number 3
R8
[R8]bgp 3
[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 78.1.1.1 as-number 2
检查BGP
R2
R7
R3
R6
宣告R1
R1
[R1]bgp 1
[R1-bgp]network 1.1.1.0 24
修改R2下一跳
R2
[R2]bgp 64512
[R2-bgp]peer 172.16.1.3 next-hop-local
[R2-bgp]peer 172.16.1.5 next-hop-local
R3作为R4的反射器
R3
[R3]bgp 64512
[R3-bgp]peer 172.16.1.4 reflect-client
这时候R4、R7才能学到R1且优
R6作为R7的反射器
R6
[R6]bgp 64513
[R6-bgp]peer 172.16.1.7 reflect-client
这时候R7学到了两条R1,bgp只优一条
具体查看谁的给的优
宣告R8
R8
[R8]bgp 3
[R8-bgp]network 8.8.8.0 24
修改R7下一跳
R7
[R7]bgp 64513
[R7-bgp]peer 172.16.1.4 next-hop-local
[R7-bgp]peer 172.16.1.6 next-hop-local
查看R1bgp
查看R3bgp
查看R4bgp
AS1、AS3学到AS2
R2
[R2]ip route-static 172.16.0.0 21 NULL 0
[R2]bgp 64512
[R2-bgp]network 172.16.0.0 21
查看R1、R8 bgp
优化
R7
[R7]bgp 64513
[R7-bgp]net 172.16.2.0 24
[R7-bgp]net 172.16.3.0 24
[R7-bgp]net 172.16.4.0 24
[R7-bgp]net 172.16.5.0 24
[R7-bgp]net 172.16.6.0 24
[R7-bgp]net 172.16.7.0 24
这时候R1、R8也能学到
汇总
R7
[R7]bgp 64513
[R7-bgp]aggregate 172.16.0.0 21 detail-suppressed
注: 在R2上空接口是手写的,在R7上空接口是自动生成的
测试