一.要求
实现R1,R7,R8之间的通信
二.配置
1.配置IP,在R1-R6上做OSPF
2.做BGP 建邻
[R2]bgp 100
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 6.6.6.6 as-number 100
[R2-bgp]peer 6.6.6.6 connect-interface loopback 0
[R2-bgp]peer 4.4.4.4 as-number 100
[R2-bgp]peer 4.4.4.4 connect-interface loopback 0
[R6]bgp 100
[R6-bgp]router-id 6.6.6.6
[R6-bgp]peer 2.2.2.2 as-number 100
[R6-bgp]peer 2.2.2.2 connect-interface loopback 0
[R6-bgp]peer 4.4.4.4 as-number 100
[R6-bgp]peer 4.4.4.4 connect-interface loopback 0
[R4]bgp 100
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 2.2.2.2 as-number 100
[R4-bgp]peer 2.2.2.2 connect-interface loopback 0
[R4-bgp]peer 6.6.6.6 as-number 100
[R4-bgp]peer 6.6.6.6 connect-interface loopback 0
3.vpn
[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-GigabitEthernet0/0/0]ip binding vpn-instance 1
[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-GigabitEthernet0/0/2]ip binding vpn-instance 2
[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-GigabitEthernet0/0/2]ip binding vpn-instance 3
4.bgp
r1
[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
[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
[r6]bgp 1
[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.mpls
r2
[r2]mpls lsr-id 2.2.2.2
[r2]mpls
[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
[r2]route recursive-lookup tunnel
r3
[r3]mpls lsr-id 3.3.3.3
[r3]mpls
[r3-mpls]mpls ldp
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]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-GigabitEthernet4/0/0]mpls
[r3-GigabitEthernet4/0/0]mpls ldp
[r3]route recursive-lookup tunnel
r4
[r4]mpls lsr-id 4.4.4.4
[r4]mpls
[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
[r4]route recursive-lookup tunnel
r5
[r5]mpls lsr-id 5.5.5.
[r5]mpls
[r5-mpls]mpls ldp
[r5-GigabitEthernet0/0/1]mpls
[r5-GigabitEthernet0/0/1]mpls ldp
[r5-GigabitEthernet0/0/2]mpls
[r5-GigabitEthernet0/0/2]mpls ldp
[r5]route recursive-lookup tunnel
r6
[r6]mpls lsr-id 6.6.6.6
[r6]mpls
[r6-mpls]mpls ldp
[r6-GigabitEthernet0/0/1]mpls
[r6-GigabitEthernet0/0/1]mpls ldp
[r6-GigabitEthernet0/0/2]mpls
[r6-GigabitEthernet0/0/2]mpls ldp
[r6]route recursive-lookup tunnel
6.与EC端建立联系
静态
[r1]ip route-static 0.0.0.0 0 12.1.1.2
[r2]route recursive-lookup tunnel
[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
RIP
[r5]rip 1 vpn
[r5]rip 1 vpn-instance 2
[r5-rip-1]version 2
[r5-rip-1]network 47.0.0.0
[r5-rip-1]import-rout bgp
[r5]bgp 1
[r5-bgp]ipv4-family vpn-instance 2
[r5-bgp-2]import-route rip 1
[r7]rip 1
[r7-rip-1]version 2
[r7-rip-1]network 7.0.0.0
[r7-rip-1]network 47.0.0.0
ospf
[r6]ospf 2 vpn-instance 3
[r6-ospf-2]area 0
[r6-ospf-2-area-0.0.0.0]network 68.1.1.6 0.0.0.0
[r6-ospf-2]import-route bgp
[r6]bgp 1
[r6-bgp]ipv4-family vpn-instance 3
[r6-bgp-3]import-route ospf 2
[r8]ospf 2 router-id 8.8.8.8
[r8-ospf-2]area 0
[r8-ospf-2-area-0.0.0.0]network 0.0.0.0 255.255.255.255
7.ping
<r1>ping 7.7.7.7
PING 7.7.7.7: 56 data bytes, press CTRL_C to break
Reply from 7.7.7.7: bytes=56 Sequence=1 ttl=252 time=50 ms
Reply from 7.7.7.7: bytes=56 Sequence=2 ttl=252 time=50 ms
Reply from 7.7.7.7: bytes=56 Sequence=3 ttl=252 time=50 ms
Reply from 7.7.7.7: bytes=56 Sequence=4 ttl=252 time=50 ms
Reply from 7.7.7.7: bytes=56 Sequence=5 ttl=252 time=40 ms
--- 7.7.7.7 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/48/50 ms
<r1>ping 8.8.8.8
PING 8.8.8.8: 56 data bytes, press CTRL_C to break
Reply from 8.8.8.8: bytes=56 Sequence=1 ttl=252 time=60 ms
Reply from 8.8.8.8: bytes=56 Sequence=2 ttl=252 time=60 ms
Reply from 8.8.8.8: bytes=56 Sequence=3 ttl=252 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=4 ttl=252 time=30 ms
Reply from 8.8.8.8: bytes=56 Sequence=5 ttl=252 time=40 ms
--- 8.8.8.8 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/46/60 ms