实验拓扑图:
一、配置底层IP以及各自区域的动态路由。
二、建立IBGP,在这里采用邻居关系全连
[r1]bgp 100
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 172.16.96.1 as-number 100
[r1-bgp]peer 172.16.96.1 connect-interface l0
[r1-bgp]peer 172.16.160.1 as-number 100
[r1-bgp]peer 172.16.160.1 connect-interface l
[r1-bgp]peer 172.16.160.1 connect-interface LoopBack 0
[r1-bgp]peer 172.16.192.1 as-number 100
[r1-bgp]peer 172.16.192.1 connect-interface l 0[r2]bgp 100
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 172.16.32.1 as-number 100
[r2-bgp]peer 172.16.32.1 connect-interface l0
[r2-bgp]peer 172.16.160.1 as-number 100
[r2-bgp]peer 172.16.160.1 connect-interface l
[r2-bgp]peer 172.16.160.1 connect-interface LoopBack 0
[r2-bgp]peer 172.16.192.1 as-number 100
[r2-bgp]peer 172.16.192.1 connect-interface l 0[r3]bgp 100
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 172.16.32.1 as-number 100
[r3-bgp]peer 172.16.32.1 connect-interface l0
[r3-bgp]peer 172.16.96.1 as-number 100
[r3-bgp]peer 172.16.96.1 connect-interface l 0
[r3-bgp]peer 172.16.192.1 as-number 100
[r3-bgp]peer 172.16.192.1 connect-interface l 0[r4]bgp 100
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 172.16.32.1 as-number 100
[r4-bgp]peer 172.16.32.1 connect-interface l 0
[r4-bgp]peer 172.16.96.1 as-number 100
[r4-bgp]peer 172.16.96.1 connect-interface l 0
[r4-bgp]peer 172.16.160.1 as-number 100
[r4-bgp]peer 172.16.160.1 connect-interface l 0[r5]bgp 101
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 192.168.0.97 as-number 101
[r5-bgp]peer 192.168.0.97 connect-interface l 0
[r5-bgp]peer 192.168.0.161 as-number 101
[r5-bgp]peer 192.168.0.161 connect-interface l 0
[r5-bgp]peer 192.168.0.193 as-number 101
[r5-bgp]peer 192.168.0.193 connect-interface l 0[r6]bgp 101t
[r6-bgp]router-id 6.6.6.6
[r6-bgp]peer 192.168.0.33 as-number 101
[r6-bgp]peer 192.168.0.33 connect-interface l 0
[r6-bgp]peer 192.168.0.161 as-number 101
[r6-bgp]peer 192.168.0.161 connect-interface l 0
[r6-bgp]peer 192.168.0.193 as-number 101
[r6-bgp]peer 192.168.0.193 connect-interface l 0[r7]bgp 101
[r7-bgp]router-id 7.7.7.7
[r7-bgp]peer 192.168.0.33 as-number 101
[r7-bgp]peer 192.168.0.33 connect-interface l 0
[r7-bgp]peer 192.168.0.97 as-number 101
[r7-bgp]peer 192.168.0.97 connect-interface l 0
[r7-bgp]peer 192.168.0.193 as-number 101
[r7-bgp]peer 192.168.0.193 connect-interface l 0[r8]bgp 101
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 192.168.0.33 as-number 101
[r8-bgp]peer 192.168.0.33 connect-interface l 0
[r8-bgp]peer 192.168.0.97 as-number 101
[r8-bgp]peer 192.168.0.97 connect-interface l 0
[r8-bgp]peer 192.168.0.161 as-number 101
[r8-bgp]peer 192.168.0.161 connect-interface l 0
三、建立EBGP
[r4]ip route-static 192.168.0.32 28 45.1.1.2
[r4]bgp 100
[r4-bgp]peer 192.168.0.33 as-number 101
[r4-bgp]peer 192.168.0.33 connect-interface l 0
[r4-bgp]peer 192.168.0.33 ebgp-max-hop //改多跳[r5]ip route-static 172.16.192.0 19 45.1.1.2
[r5]bgp 101
[r5-bgp]peer 172.16.192.1 as-number 101
[r5-bgp]peer 172.16.192.1 connect-interface l 0
[r5-bgp]peer 172.16.192.1 ebgp-max-hop[r5-bgp]peer 192.168.0.97 next-hop-local //改下一跳
[r5-bgp]peer 192.168.0.161 next-hop-local
[r5-bgp]peer 192.168.0.193 next-hop-local[r4-bgp]peer 172.16.32.1 next-hop-local
[r4-bgp]peer 172.16.160.1 next-hop-local
[r4-bgp]peer 172.16.96.1 next-hop-local
四、as100到as101只有汇总可以通过(宣告汇总后拒绝明细)
[r4]ip route-static 172.16.0.0 16 NULL 0
[r4]bgp 100
[r4-bgp]network 172.16.0.0 16
[r4]ip ip-prefix aa deny 172.16.0.0 19
[r4]ip ip-prefix aa deny 172.16.64.0 19
[r4]ip ip-prefix aa deny 172.16.128.0 19
[r4]ip ip-prefix aa deny 172.16.192.0 19
[r4]ip ip-prefix aa deny 172.16.224.0 19
[r4]ip ip-prefix aa deny 172.16.32.0 20
[r4]ip ip-prefix aa deny 172.16.48.0 20
[r4]ip ip-prefix aa deny 172.16.96.0 20
[r4]ip ip-prefix aa deny 172.16.112.0 20
[r4]ip ip-prefix aa deny 172.16.160.0 20
[r4]ip ip-prefix aa deny 172.16.176.0 20
[r4]ip ip-prefix aa permit 0.0.0.0 0 less-equal 32
[r4-bgp]peer 192.168.0.33 ip-prefix aa export
[r5]ip route-static 192.168.0.0 24 NULL 0
[r5]bgp 101
[r5-bgp]network 192.168.0.0 24
五、只保留R8上的汇总
[r8]bgp 101
[r8-bgp]network 192.168.0.193 27
[r8-bgp]network 192.168.0.225 27
全网可达完成