一、实验拓扑
二、配置 IP地址,环回地址
[r1]nt g0/0/0
[r1-GigabitEthernet0/0/0]ip add 11.1.1.1 24
[r1-GigabitEthernet0/0/0]int L0
[r1-LoopBack0]ip add 1.1.1.1 32
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 11.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 22.1.1.1 24
[r2-GigabitEthernet0/0/1]int g0/0/2
[r2-GigabitEthernet0/0/2]ip add 55.1.1.1 24
[r2-GigabitEthernet0/0/2]int L0
[r2-LoopBack0]ip add 2.2.2.2 32
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 22.1.1.2 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 33.1.1.1 24
[r3-GigabitEthernet0/0/1]int L0
[r3-LoopBack0] ip add 3.3.3.3 32
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 33.1.1.2 24
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 44.1.1.1 24
[r4-GigabitEthernet0/0/1]int L0
[r4-LoopBack0]ip add 4.4.4.4 32
[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 55.1.1.2 24
[r5-GigabitEthernet0/0/0]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 66.1.1.1 24
[r5-GigabitEthernet0/0/1]int L0
[r5-LoopBack0]ip add 5.5.5.5 32
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 66.1.1.2 24
[r6-GigabitEthernet0/0/0]int g0/0/1
[r6-GigabitEthernet0/0/1]ip add 77.1.1.1 24
[r6-GigabitEthernet0/0/1]int l0
[r6-LoopBack0]ip add 6.6.6.6 32
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 44.1.1.2 24
[r7-GigabitEthernet0/0/0]int g0/0/1
[r7-GigabitEthernet0/0/1]ip add 77.1.1.2 24
[r7-GigabitEthernet0/0/1]int g0/0/2
[r7-GigabitEthernet0/0/2]ip add 88.1.1.1 24
[r7-GigabitEthernet0/0/2]int L0
[r7-LoopBack0]ip add 7.7.7.7 32
[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ip add 88.1.1.2 24
[r8-GigabitEthernet0/0/0]int l0
[r8-LoopBack0]ip add 8.8.8.8 32
三、书写路由表
[r1]bgp 100
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 11.1.1.2 as-number 200
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 22.1.1.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 55.1.1.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 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 22.1.1.2 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 33.1.1.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 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 33.1.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 44.1.1.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 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 66.1.1.1 0.0.0.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 55.1.1.2 0.0.0.0
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 77.1.1.1 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 66.1.1.2 0.0.0.0
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 7.7.7.7 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 44.1.1.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 77.1.1.2 0.0.0.0
四、用BGP建立邻居关系
[r2]bgp 64512
[r2-bgp]router-id 2.2.2.2
[r2-bgp]confederation id 200
[r2-bgp]confederation peer-as 64513
[r2-bgp]peer 3.3.3.3 as-number 64512
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r2-bgp]peer 5.5.5.5 as-number 64513
[r2-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r2-bgp]peer 5.5.5.5 ebgp-max-hop
[r2-bgp]peer 11.1.1.1 as-number 100
[r2-bgp]peer 3.3.3.3 next-hop-local
[r3]bgp 64512
[r3-bgp]router-id 3.3.3.3
[r3-bgp]confederation id 200
[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 64512
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r3-bgp]peer 2.2.2.2 reflect-client
[r3-bgp]peer 4.4.4.4 reflect-client
[r4]bgp 64512
[r4-bgp]confederation id 200
[r4-bgp]confederation peer-as 64513
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-number 64512
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r4-bgp]peer 7.7.7.7 as-number 64513
[r4-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[r4-bgp]peer 7.7.7.7 ebgp-max-hop
[r4-bgp]peer 3.3.3.3 next-hop-local
[r5]bgp 64513
[r5-bgp]router-id 5.5.5.5
[r5-bgp]confederation id 200
[r5-bgp]confederation peer-as 6451
[r5-bgp]peer 2.2.2.2 as-number 64512
[r5-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r5-bgp]peer 6.6.6.6 as-number 64513
[r5-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r5-bgp]peer 2.2.2.2 ebgp-max-hop
[r5-bgp]peer 6.6.6.6 next-hop-local
[r6]bgp 64513
[r6-bgp]router-id 6.6.6.6
[r6-bgp]confederation id 200
[r6-bgp]peer 5.5.5.5 as-number 64513
[r6-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r6-bgp]peer 7.7.7.7 as-number 64513
[r6-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[r6-bgp]peer 5.5.5.5 reflect-client
[r6-bgp]peer 7.7.7.7 reflect-client
[r7]bgp 64513
[r7-bgp]router-id 7.7.7.7
[r7-bgp]peer 6.6.6.6 as-number 64513
[r7-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r7-bgp]confederation id 200
[r7-bgp]confederation peer-as 64512
[r7-bgp]peer 4.4.4.4 as-number 64512
[r7-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r7-bgp]peer 4.4.4.4 ebgp-max-hop
[r7-bgp]peer 88.1.1.2 as-number 300
[r7-bgp]peer 6.6.6.6 next-hop-local
[r8]bgp 300
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 88.1.1.1 as-number 200
五、重发布
[r1]bgp 100
[r1-bgp]import-route direct
[r2]bgp 64512
[r2-bgp]import-route ospf 1
[r7]bgp 64513
[r7-bgp]import-route ospf 1
[r8]bgp 300
[r8-bgp]import-route direct
六、使用路由策略
r5]ip ip
[r5]ip ip-prefix xx permit 4.4.4.4 32
[r5]route-policy yy permit node 10
[r5-route-policy]if-match ip-prefix xx
[r5-route-policy]apply origin igp
[r5]route-policy yy permit node 20
[r5]bgp 64513
[r5-bgp]peer 6.6.6.6 route-policy yy import
实验完成!