搭建拓扑 1.划分出相应的ip地址 2.在AS2内开启ospf协议
[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.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 172.16.32.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 172.16.64.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 172.16.1.1 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 172.16.64.2 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 172.16.96.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 172.16.2.1 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 172.16.96.2 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 172.16.224.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 172.16.128.1 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.32.2 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.160.1 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 172.16.129.1 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.160.2 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.192.1 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 172.16.129.1 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.160.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]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.1 as-number 64512
[R2-bgp]peer 172.16.1.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.128.1 as-number 64513
[R2-bgp]peer 172.16.128.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.128.1 ebgp-max-hop 2
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.0.1 as-number 64512
[R3-bgp]peer 172.16.0.1 connect-interface LoopBack 0
[R3-bgp]peer 172.16.2.1 as-number 64512
[R3-bgp]peer 172.16.2.1 connect-interface LoopBack 0
[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.1 as-number 64512
[R4-bgp]peer 172.16.1.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.130.1 as-number 64513
[R4-bgp]peer 172.16.130.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.130.1 ebgp-max-hop 2
[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.0.1 as-number 64512
[R5-bgp]peer 172.16.0.1 connect-interface LoopBack 0
[R5-bgp]peer 172.16.0.1 ebgp-max-hop 2
[R5-bgp]peer 172.16.129.1 as-number 64512
[R5-bgp]peer 172.16.129.1 connect-interface LoopBack 0
[R6]bgp 64513
[R6-bgp]router-id 6.6.6.6
[R6-bgp]confederation id 2
[R6-bgp]peer 172.16.128.1 as-number 64513
[R6-bgp]peer 172.16.128.1 connect-interface LoopBack 0
[R6-bgp]peer 172.16.130.1 as-number 64513
[R6-bgp]peer 172.16.130.1 connect-interface LoopBack 0
[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.129.1 as-number 64513
[R7-bgp]peer 172.16.129.1 connect-interface LoopBack 0
[R7-bgp]peer 172.16.2.1 as-number 64512
[R7-bgp]peer 172.16.2.1 connect-interface LoopBack 0
[R7-bgp]peer 172.16.2.1 ebgp-max-hop 2
[R7-bgp]peer 23.1.1.2 as-number 3
[R8]bgp 3
[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 23.1.1.1 as-number 2
4.宣告网段
R1]bgp 1
[R1-bgp]network 10.1.1.0 24
[R2]bgp 64512
[R2-bgp]peer 172.16.2.1 next-hop-local
[R2-bgp]peer 172.17.4.1 next-hop-local
[R2-bgp]peer 172.16.4.1 next-hop-local
此时因为IBGP水平分割,所以R3不会把路由给R4,6不会给7 R3开反射器,会把路由给7,7也会把路由给6,5也会给6路由,6选择一条。 为了稳妥3/6都开反射器
[R3]bgp 64512
[R3-bgp]peer 172.16.3.1 reflect-client
R6上学到两条,优第一条(从5.5.5.5传过来的)所有属性都一样,选router ID小的
[R6]bgp 64513
[R6-bgp]peer 172.16.4.1 reflect-client
此时,R7上学到两条,但是优选4的,因为4/7是EBGP关系。
[R7]bgp 64513
[R7-bgp]peer 172.16.3.1 next-hop-local
[R7-bgp]peer 172.16.5.1 next-hop-local
[R8]bgp 3
[R8-bgp]network 10.1.2.0 24
[R2]ip route-static 172.16.0.0 21 NULL 0
[R2]bgp 64512
[R2-bgp]network 172.16.0.0 21
[R7]ip route-static 172.16.0.0 21 NULL 0
[R7]bgp 64513
[R7-bgp]network 172.16.0.0 21
使用GRE
[R1]int Tunnel 0/0/0
[R1-Tunnel0/0/0]ip address 10.1.3.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]source 10.1.1.1
[R1-Tunnel0/0/0]destination 10.1.2.1
[R8]int Tunnel 0/0/0
[R8-Tunnel0/0/0]ip address 10.1.3.2 24
[R8-Tunnel0/0/0]tunnel-protocol gre
[R8-Tunnel0/0/0]source 10.1.2.1
[R8-Tunnel0/0/0]destination 10.1.1.1
[R8]ip route-static 192.168.1.0 24 Tunnel 0/0/0
[R1]ip route-static 192.168.2.0 24 10.1.3.2
|