最后效果:r1能ping通r8,r4路由表有r1-r8环回,r4bgp路由表已优化
代码;
[r1]
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 12.1.1.1 0.0.0.0
bgp 64512
router-id 1.1.1.1
confederation id 100 #声明AS100是自己的大AS
peer 2.2.2.2 as-number 64512
peer 2.2.2.2 connect-interface LoopBack0
[r2]
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 12.1.1.2 0.0.0.0
network 23.1.1.1 0.0.0.0
bgp 64512
router-id 2.2.2.2
confederation id 100
peer 1.1.1.1 as-number 64512
peer 1.1.1.1 connect-interface LoopBack0
peer 3.3.3.3 as-number 64512
peer 3.3.3.3 connect-interface LoopBack0
peer 1.1.1.1 reflect-client #做反射器,解决ibgp之间水平分割问题
peer 3.3.3.3 reflect-client
[r3]
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.1.1.2 0.0.0.0
network 34.1.1.1 0.0.0.0
bgp 64512
router-id 3.3.3.3
confederation id 100 import ospf 1 #不写这个r1-r3的bgp路由表会有问题,暂时不知道缘由
confederation peer-as 64513 #小AS的ebgp之间记得先互相写这个命令
peer 2.2.2.2 as-number 64512
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 64513
peer 4.4.4.4 ebgp-max-hop 255 #用环回口建立ebgp,TTL跳数会为1要改为max
peer 4.4.4.4 connect-interface LoopBack0
peer 2.2.2.2 next-hop-local #优化ibgp下一跳问题
[r4] #r4不写import是因为写了会多出来一堆重复的bgp路由条目
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.1.1.2 0.0.0.0
network 45.1.1.1 0.0.0.0
bgp 64513
router-id 4.4.4.4
confederation id 100
confederation peer-as 64512 #小AS的ebgp之间记得互相写这个命令
peer 3.3.3.3 as-number 64512
peer 3.3.3.3 ebgp-max-hop 255
peer 3.3.3.3 connect-interface LoopBack0
peer 5.5.5.5 as-number 64513
peer 5.5.5.5 connect-interface LoopBack0
[r5]
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 45.1.1.2 0.0.0.0
bgp 64513
router-id 5.5.5.5
confederation id 100
peer 4.4.4.4 as-number 64513
peer 4.4.4.4 connect-interface LoopBack0
peer 56.1.1.2 as-number 101
peer 4.4.4.4 next-hop-local
[r6]
rip 1
version 2
network 6.0.0.0
network 67.0.0.0
bgp 101
router-id 6.6.6.6
peer 7.7.7.7 as-number 101
peer 7.7.7.7 connect-interface LoopBack0
peer 56.1.1.1 as-number 100
import-route rip 1
peer 7.7.7.7 next-hop-local
[r7]
rip 1
version 2
network 7.0.0.0
network 67.0.0.0
network 78.0.0.0
bgp 101
router-id 7.7.7.7
peer 6.6.6.6 as-number 101
peer 6.6.6.6 connect-interface LoopBack0
peer 8.8.8.8 as-number 101
peer 8.8.8.8 connect-interface LoopBack0
peer 6.6.6.6 reflect-client
peer 8.8.8.8 reflect-client
[r8]
rip 1
version 2
network 78.0.0.0
network 8.0.0.0
bgp 101
router-id 8.8.8.8
peer 7.7.7.7 as-number 101
peer 7.7.7.7 connect-interface LoopBack0