1.配置IP地址
2.OSPF配置
[r5-ospf-100-area-0.0.0.0]network 16.0.0.1 0.0.0.0
[r5-ospf-100-area-0.0.0.0]network 23.0.0.2 0.0.0.0
[r5-ospf-100-area-0.0.0.0]network 14.0.0.2 0.0.0.0
3.MPLS配置
[r2]mpls lsr-id 2.2.2.2
[r2-mpls]mpls 1b
[r2-GigabitEthernet0/0/1]mpls ldp
[r2-GigabitEthernet0/0/2]mpls ldp
[r3]mpls lsr-id 3.3.3.3
[r3-mpls]mpl
[r3-mpls]mpls ld
[r3-GigabitEthernet0/0/0]mpls ldp
[r3-GigabitEthernet0/0/1]mpls ldp
[r3-GigabitEthernet0/0/2]mpls ldp
[r4]mpls lsr-id 4.4.4.4
[r4-mpls]mpls ld
[r4-GigabitEthernet0/0/0]mpls ldp
[r4-GigabitEthernet0/0/1]mpls ldp
[r4-GigabitEthernet0/0/2]mpls ldp
[r5]mpls lsr-id 5.5.5.5
[r5-mpls]mpls ld
[r5-GigabitEthernet0/0/0]mpls ldp
[r5-GigabitEthernet0/0/1]mpls ld
[r5-GigabitEthernet0/0/1]mpls ldp
[r5-GigabitEthernet0/0/2]mpls ldp
[r6]mpls lsr-id 6.6.6.6
[r6-mpls]mpls ld
[r6-GigabitEthernet0/0/0]mpls ldp
[r6-GigabitEthernet0/0/1]mpls ldp
[r6-GigabitEthernet0/0/2]mpls ldp
4.建立BGP
[r2-bgp]peer 5.5.5.5 as-number 100
[r2-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 5.5.5.5 enable
[r2-bgp]peer 6.6.6.6 as-number 100
[r2-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 6.6.6.6 enable
[r2]route recursive-lookup tunnel
[r5-bgp]peer 2.2.2.2 as-number 100
[r5-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r5-bgp]ipv4-family vpnv4
[r5-bgp-af-vpnv4]peer 2.2.2.2 enable
[r5-bgp]peer 6.6.6.6 as-number 100
[r5-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r5-bgp]ipv4-family vpnv4
[r5-bgp-af-vpnv4]peer 6.6.6.6 enable
[r5]route recursive-lookup tunnel
[r6-bgp]peer 2.2.2.2 as-number 100
[r6-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r6-bgp]ipv4-family vpnv4
[r6-bgp-af-vpnv4]peer 2.2.2.2 enable
[r6-bgp]peer 5.5.5.5 as-number 100
[r6-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r6-bgp]ipv4-family vpnv4
[r6-bgp-af-vpnv4]peer 5.5.5.5 enable
[r6]route recursive-lookup tunnel
5.建立VPN
[r2]ip vpn-instance 1
[r2-vpn-instance-1]route-distinguisher 100:1
[r2-vpn-instance-1-af-ipv4]vpn-target 1:1 export-extcommunity
[r2-vpn-instance-1-af-ipv4]vpn-target 2:2 3:3 import-extcommunity
[r2-vpn-instance-1-af-ipv4]q
[r2-GigabitEthernet0/0/0]ip binding vpn-instance 1
[r5-vpn-instance-2]route-distinguisher 100:2
[r5-vpn-instance-2-af-ipv4]vpn-target 2:2 export-extcommunity
[r5-vpn-instance-2-af-ipv4]vpn-target 1:1 3:3 import-extcommunity
[r5-GigabitEthernet0/0/2]ip binding vpn-instance 2
r5-GigabitEthernet0/0/2]ip address 16.0.0.1 24
[r6-vpn-instance-3]route-distinguisher 100:3
[r6-vpn-instance-3-af-ipv4]vpn-target 3:3 export-extcommunity
[r6-vpn-instance-3-af-ipv4]vpn-target 1:1 2:2 import-extcommunity
[r6-GigabitEthernet0/0/2]ip binding vpn-instance 3
[r6-GigabitEthernet0/0/2]ip address 17.0.0.1 24
6.R1 R2缺省路由
[r1]ip route-static 0.0.0.0 0 10.0.0.2
[r2]ip route-static vpn-instance 1 1.1.1.1 24 10.0.0.1
7.R2重发布静态
[r2-bgp]ipv4-family vpn-instance 1
[r2-bgp-1]import-route static
[r7-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
8.双向重发布
[r5]ospf 1 vpn-instance 2
[r5-ospf-1]a
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]ne
[r5-ospf-1-area-0.0.0.0]network 16.0.0.1 0.0.0.0
[r5-ospf-1]import-route bgp
[r5-bgp]ipv4-family vpn-instance 2
[r5-bgp-2]import-route ospf 1
[r6-rip-1]version 2
[r6-rip-1]network 17.0.0.0
[r6-rip-1]import-route bgp
[r6]bgp 100
[r6-bgp]ip
[r6-bgp]ipv4-family v
[r6-bgp]ipv4-family vpnv4
[r6-bgp]ipv4-family vpn-instance 3
[r6-bgp-3]im
[r6-bgp-3]import-route rip
[r6-bgp-3]import-route rip 1
[r8]rip
[r8]rip 1
[r8-rip-1]v
[r8-rip-1]version 2
[r8-rip-1]ne
[r8-rip-1]network 8.0.0.0
[r8-rip-1]network 17.0.0.0