1.连接好线路,配置接口,环回ip
配置ospf R2 R3 R4 R5 R6 R7
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R3-LoopBack1]ospf network-type broadcast
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 2
[R1-bgp]peer 15.1.1.5 as-number 2
[R1]ip ip-prefix as permit 172.16.2.0 24
[R1]route-policy as permit node 10
[R1-route-policy]if-match ip-prefix as
[R1-route-policy]apply as-path 222 additive
[R1]route-policy as permit node 20
[R1]bgp1
[R1-bgp]peer 12.1.1.2 route-policy as import
配置mpls
[R2]mpls lsr-id 172.16.0.2
[R2]mpls
[R2-mpls]mpls ldp
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]mpls
[R2-GigabitEthernet0/0/1]mpls ldp
[R2-GigabitEthernet0/0/2]mpls
[R2-GigabitEthernet0/0/2]mpls ldp
配置bgp
[R2]bgp 2
[R2-bgp]router-id 172.16.0.2
[R2-bgp]peer 12.1.1.1 as-number 1
[R2-bgp]peer 172.16.0.5 as-number 2
[R2-bgp]peer 172.16.0.5 connect-interface LoopBack 0
[R2-bgp]peer 172.16.0.5 next-hop-local
[R2-bgp]peer 172.16.0.7 as-number 2
[R2-bgp]peer 172.16.0.7 connect-interface LoopBack 0
[R2-bgp]peer 172.16.0.7 next-hop-local
宣告bgp
[R2-bgp]network 172.16.0.0 21
[R2-bgp]network 172.16.2.0 24
[R2-bgp]network 172.16.3.0 24
[R2-bgp]network 172.16.4.0 24
[R2]ip route-static 172.16.0.0 21 NULL 0
其余路由同上述