R1

R8

运行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.1.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 172.16.1.9 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 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 172.16.1.2 0.0.0.0

[R3-ospf-1-area-0.0.0.0]network 172.16.1.17 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.1.180.0.0.0
[R4-ospf-1-area-0.0.0.0]network 172.161.1.25 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 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.1.10 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.1.33 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.1.340.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.1.410.0.0.0
[R6-ospf-1-area-0.0.0.0]network 6.6.6.6 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 172.16.1.26 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 172.16.1.42 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 7.7.7.7 0.0.0.0

路由器之间的BGP建邻

R2-R7各创建一个环回,用来非直连建邻

[R1]bgp 1
[R1-bgp]route-select
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.0.0.2 as 2

[R2]bgp 64512
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.0.0.1 as 1
[R2-bgp]peer 3.3.3.3 as-number 64512
[R2-bgp]peer 3.3.3.3 connect-interface l0
[R2-bgp]confederation peer-as 64513
[R2-bgp]peer 5.5.5.5 as 64513
[R2-bgp]peer 5.5.5.5 connect-interface l0
[R2-bgp]peer 5.5.5.5 ebgp-max-hop

[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 2.2.2.2 as-number 64512
[R3-bgp]peer 2.2.2.2 connect-interface l0
[R3-bgp]peer 4.4.4.4 as-number 64512
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0

[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 2.2.2.2 as-number 64512
[R3-bgp]peer 2.2.2.2 connect-interface l0
[R3-bgp]peer 4.4.4.4 as-number 64512
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0

[R7-bgp]peer 78.0.0.2 as 3

[R5]bgp 64513
[R5-bgp]router-id 4.4.4.4
[R5-bgp]confederation id 2
[R5-bgp]confederation peer-as 64512
[R5-bgp]peer 2.2.2.2 as-number 64512
[R5-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R5-bgp]peer 2.2.2.2 ebgp-max-hop
[R5-bgp]peer 6.6.6.6 as-number 64513
[R5-bgp]peer 6.6.6.6 connect-interface l0

​​​​​​​[R4]bgp 64512
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 2
[R4-bgp]peer 3.3.3.3 as 64512
[R4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R4-bgp]confederation peer-as 64513
[R4-bgp]peer 7.7.7.7 as 64513
[R4-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[R4-bgp]peer 7.7.7.7 ebgp-max-hop

[R6]bgp 64513
[R6-bgp]router-id 6.6.6.6
[R6-bgp]confederation id 2
[R6-bgp]peer 5.5.5.5 as 645123
[R6-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R6-bgp]peer 7.7.7.7 as 64513
[R6-bgp]peer 7.7.7.7 connect-interface LoopBack 0

[R7]bgp 64513
[R7-bgp]confederation id 2
[R7-bgp]peer 6.6.6.6 as 64513
[R7-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[R7-bgp]confederation peer-as 64512
[R7-bgp]peer 4.4.4.4 as 64512
[R7-bgp]peer 4.4.4.4 connect-interface LoopBack 0

[R7-bgp]peer 4.4.4.4 ebgp-max-hop

​​​​​​​

[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 78.0.0.1 as 2​​​​​​​

​​​​​​​

​​​​​​​发布路由

[R1-bgp]network 10.1.1.0 24

[R8-bgp]network 11.1.1.0 24

查看BGP路由,路由不可用,原因:没有修改下一跳属性

查看R4的BGP路由表,是空的,需要做路由反射器

[R2-bgp]peer 3.3.3.3 next-hop-local
[R2-bgp]peer 5.5.5.5 next-hop-local

[R7-bgp]peer 4.4.4.4 next-hop-local
[R7-bgp]peer 6.6.6.6 next-hop-local

做路由反射器,反射路由

[R6-bgp]peer 5.5.5.5 reflect-client
[R3-bgp]peer 2.2.2.2 reflect-client

测试 两个环回的是否可以通信:

做一个汇总网段指向空接口,发布汇总路由

[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

给192.168.1.0和2.0建立一个VPN隧道,使用环回接口作为GRE封装的目标和源IP,因为12.0.0.1和78.0.0.2不能进行VPN通信,不可用。

[R1]ip route-sta 192.168.2.0 24 192.168.3.2

[R8]ip route-static 192.168.1.0 24 192.168.3.1

测试: