一、实验拓扑图
二、实验需求
1.合理规划IP地址
2.R1使用静态,R7运行RIP,R8运行OSPF
3.CE端实现通信
三、实验步骤
1.配置IP地址
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[R2-GigabitEthernet0/0/1]ip add 23.1.1.1 24
[R2-GigabitEthernet0/0/2]ip add 24.1.1.1 24
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
[R3-GigabitEthernet0/0/1]ip add 35.1.1.1 24
[R3-GigabitEthernet0/0/2]ip add 36.1.1.1 24
[R3-GigabitEthernet4/0/0]ip add 34.1.1.1 24
[R4-GigabitEthernet0/0/0]ip add 24.1.1.2 24
[R4-GigabitEthernet0/0/1]ip add 46.1.1.1 24
[R4-GigabitEthernet0/0/2]ip add 45.1.1.1 24
[R4-GigabitEthernet4/0/0]ip add 34.1.1.2 24
[R4-LoopBack0]ip add 4.4.4.4 32
[R5-LoopBack0]ip add 5.5.5.5 32
[R5-GigabitEthernet0/0/0]ip add 35.1.1.2 24
[R5-GigabitEthernet0/0/1]ip add 57.1.1.1 24
[R5-GigabitEthernet0/0/2]ip add 45.1.1.2 24
[R6-LoopBack0]ip add 6.6.6.6 32
[R6-GigabitEthernet0/0/0]ip add 46.1.1.2 24
[R6-GigabitEthernet0/0/1]ip add 68.1.1.1 24
[R6-GigabitEthernet0/0/2]ip add 36.1.1.2 24
[R7-LoopBack0]ip add 7.7.7.7 32
[R7-GigabitEthernet0/0/0]ip add 57.1.1.2 24
[R8-GigabitEthernet0/0/0]ip add 68.1.1.2 24
[R8-LoopBack0]ip add 8.8.8.8 32
2.运营商R2-R3-R4-R5-R6运行OSPF
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 23.1.1.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 24.1.1.1 0.0.0.0
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[R5]ospf 1 router-id 5.5.5.5
[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 35.1.1.2 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 45.1.1.2 0.0.0.0
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 36.1.1.2 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 46.1.1.2 0.0.0.0
3.PE端创建VPN-instance
[R2]ip vpn-instance 1
[R2-vpn-instance-1]route-distinguisher 1: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-vpn-instance-1]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]undo ip add
[R2-GigabitEthernet0/0/0]ip binding vpn-instance 1
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[R5]ip vpn-instance 2
[R5-vpn-instance-2]route-distinguisher 2: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-vpn-instance-2-af-ipv4]q
[R5-vpn-instance-2]q
[R5-GigabitEthernet0/0/1]undo ip add
[R5-GigabitEthernet0/0/1]ip binding vpn-instance 2
[R5-GigabitEthernet0/0/1]ip add 57.1.1.1 24
[R6]ip vpn-instance 3
[R6-vpn-instance-3]route-distinguisher 3:3
[R6-vpn-instance-3-af-ipv4]vpn-target 1:1 2:2 import-extcommunity
[R6-vpn-instance-3-af-ipv4]vpn-target 3:3 export-extcommunity
[R6-vpn-instance-3-af-ipv4]q
[R6-vpn-instance-3]q
[R6-GigabitEthernet0/0/1]undo ip add
[R6-GigabitEthernet0/0/1]ip binding vpn-instance 3
[R6-GigabitEthernet0/0/1]ip add 68.1.1.1 24
4.在R2,R5,R6做BGP
[R2]bgp 1
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 5.5.5.5 as-number 1
[R2-bgp]peer 5.5.5.5 connect-interface lo 0
[R2-bgp]peer 6.6.6.6 as-number 1
[R2-bgp]peer 6.6.6.6 connect-interface lo 0
[R2-bgp]ipv4-family vpnv4
[R2-bgp-af-vpnv4]peer 5.5.5.5 enable
[R2-bgp-af-vpnv4]peer 5.5.5.5 next-hop-local
[R2-bgp-af-vpnv4]peer 6.6.6.6 enable
[R2-bgp-af-vpnv4]peer 6.6.6.6 next-hop-local
[R5]bgp 1
[R5-bgp]router-id 5.5.5.5
[R5-bgp]peer 2.2.2.2 as-number 1
[R5-bgp]peer 2.2.2.2 connect-interface lo 0
[R5-bgp]peer 6.6.6.6 as-number 1
[R5-bgp]peer 6.6.6.6 connect-interface lo 0
[R5-bgp]ipv4-family vpnv4
[R5-bgp-af-vpnv4]peer 2.2.2.2 enable
[R5-bgp-af-vpnv4]peer 2.2.2.2 next-hop-local
[R5-bgp-af-vpnv4]peer 6.6.6.6 enable
[R5-bgp-af-vpnv4]peer 6.6.6.6 next-hop-local
[R6]bgp 1
[R6-bgp]ro
[R6-bgp]route-select
[R6-bgp]router-id 6.6.6.6
[R6-bgp]peer 2.2.2.2 as-number 1
[R6-bgp]peer 2.2.2.2 connect-interface lo 0
[R6-bgp]peer 5.5.5.5 as-number 1
[R6-bgp]peer 5.5.5.5 connect-interface lo 0
[R6-bgp]ipv4-family vpnv4
[R6-bgp-af-vpnv4]peer 2.2.2.2 enable
[R6-bgp-af-vpnv4]peer 2.2.2.2 next-hop-local
[R6-bgp-af-vpnv4]peer 5.5.5.5 enable
[R6-bgp-af-vpnv4]peer 5.5.5.5 next-hop-local
5.R2,R3,R4,R5,R6做MPLS
[R2]mpls lsr-id 2.2.2.2
[R2]mpls
Info: Mpls starting, please wait... OK!
[R2-mpls]mpls ld
[R2-GigabitEthernet0/0/1]mpls
[R2-GigabitEthernet0/0/1]mpls ldp
[R2-GigabitEthernet0/0/2]mpls
[R2-GigabitEthernet0/0/2]mpls ldp
[R3]mpls lsr-id 3.3.3.3
[R3]mpls
Info: Mpls starting, please wait... OK!
[R3-mpls]mpls ldp
[R3-GigabitEthernet0/0/1]mpls
[R3-GigabitEthernet0/0/1]mpls ldp
[R3-GigabitEthernet0/0/2]mpls
[R3-GigabitEthernet0/0/2]mpls ldp
[R3-GigabitEthernet0/0/0]mpls
[R3-GigabitEthernet0/0/0]mpls ldp
[R3-GigabitEthernet4/0/0]mpls
[R3-GigabitEthernet4/0/0]mpls ldp
[R4]mpls lsr-id 4.4.4.4
[R4]mpls
Info: Mpls starting, please wait... OK!
[R4-mpls]mpls ldp
[R4-GigabitEthernet0/0/0]mpls
[R4-GigabitEthernet0/0/0]mpls ldp
[R4-GigabitEthernet0/0/1]mpls
[R4-GigabitEthernet0/0/1]mpls ldp
[R4-GigabitEthernet0/0/2]mpls
[R4-GigabitEthernet0/0/2]mpls ldp
[R4-GigabitEthernet4/0/0]mpls
[R4-GigabitEthernet4/0/0]mpls ldp
[R5]mpls lsr-id 5.5.5.5
[R5]mpls
Info: Mpls starting, please wait... OK!
[R5-mpls]mpls ldp
[R5-GigabitEthernet0/0/0]mpls
[R5-GigabitEthernet0/0/0]mpls ldp
[R5-GigabitEthernet0/0/2]mpls
[R5-GigabitEthernet0/0/2]mpls ldp
[R6]mpls lsr-id 6.6.6.6
[R6]mpls
Info: Mpls starting, please wait... OK!
[R6-mpls]mpls ldp
[R6-GigabitEthernet0/0/0]mpls
[R6-GigabitEthernet0/0/0]mpls ldp
[R6-GigabitEthernet0/0/2]mpls
[R6-GigabitEthernet0/0/2]mpls ldp
[R2]route recursive-lookup tunnel
[R3]route recursive-lookup tunnel
[R4]route recursive-lookup tunnel
[R5]route recursive-lookup tunnel
[R6]route recursive-lookup tunnel
6.CE端实现通信
R1使用静态,R7使用RIP,R8使用OSPF
[R1]ip route-static 0.0.0.0 0 12.1.1.2
[R2]ip route-static vpn-instance 1 1.1.1.1 32 12.1.1.1
[R2]bgp 1
[R2-bgp]ipv4-family vpn-instance 1
[R2-bgp-1]import-route direct
[R2-bgp-1]import-route static
[R5]rip 1 vpn-instance 2
[R5-rip-1]version 2
[R5-rip-1]network 57.0.0.0
[R5-rip-1]import-route bgp
[R5]bgp 1
[R5-bgp]ipv4-family vpn-instance 2
[R5-bgp-1]import-route rip 1
[R6]ospf 2 vpn-instance 3
[R6-ospf-2-area-0.0.0.0]network 68.1.1.1 0.0.0.0
[R6-ospf-2]import-route bgp
[R6]bgp 1
[R6-bgp]ipv4-family vpn-instance 3
[R6-bgp-1]import-route ospf 2
[R7]rip 1
[R7-rip-1]version 2
[R7-rip-1]network 7.0.0.0
[R7-rip-1]network 57.0.0.0
[R8]ospf 2 router-id 8.8.8.8
[R8-ospf-2-area-0.0.0.0]network 0.0.0.0 255.255.255.255