一、题目要求
1、R1与R5MPLS VPN
2、R6与R7MPLS VPN
3、R7可以访问R2/3/4的环回
二、拓扑图
三、实验步骤
如图配置IP
1.公网互通,进行相关配置
开启MPLS服务
R2
[R2]mpls lsr-id 2.2.2.2
[R2]mpls
[R2-mpls]mpls ldp
[R2-mpls-ldp]int g0/0/0
[R2-GigabitEthernet0/0/0]mpls
[R2-GigabitEthernet0/0/0]mpls ldp
R3
[R3]mpls lsr-id 3.3.3.3
[R3] mpls
[R3-mpls] mpls ldp
[R3-mpls-ldp]int g0/0/1
[R3-GigabitEthernet0/0/1] mpls
[R3-GigabitEthernet0/0/1] mpls ldp
[R3-GigabitEthernet0/0/1]int g0/0/0
[R3-GigabitEthernet0/0/0] mpls
[R3-GigabitEthernet0/0/0] mpls ldp
R4
[R4]mpls lsr-id 4.4.4.4
[R4] mpls\n[R4-mpls] mpls ldp
[R4-mpls-ldp]int g0/0/1
[R4-GigabitEthernet0/0/1] mpls
[R4-GigabitEthernet0/0/1] mpls ldp
创建VRF空间
R2
[R2]ip vpn-instance b1
[R2-vpn-instance-b1]ipv4-family
[R2-vpn-instance-b1-af-ipv4]route-distinguisher 1:1
[R2-vpn-instance-b1-af-ipv4]vpn-target 1:1
[R2]ip vpn-instance a1
[R2-vpn-instance-a1]ipv4-family
[R2-vpn-instance-a1-af-ipv4]route-distinguisher 2:2
[R2-vpn-instance-a1-af-ipv4]vpn-target 2:2
R4
[R4]ip vpn-instance b2
[R4-vpn-instance-b2]ipv4-family
[R4-vpn-instance-b2-af-ipv4]route-distinguisher 1:1
[R4-vpn-instance-b2-af-ipv4]vpn-target 1:1
[R4]ip vpn-instance a2
[R4-vpn-instance-a2]ipv4-family
[R4-vpn-instance-a2-af-ipv4]route-distinguisher 2:2
[R4-vpn-instance-a2-af-ipv4]vpn-target 2:2
绑定两个空间并配置对应IP
[R2-GigabitEthernet0/0/1]ip binding vpn-instance b1
[R2-GigabitEthernet0/0/1]ip address 192.168.2.2 24
[R2-GigabitEthernet0/0/2]ip binding vpn-instance a1
[R2-GigabitEthernet0/0/2]ip address 192.168.2.2 24
[R4-GigabitEthernet0/0/0]ip binding vpn-instance b2
[R4-GigabitEthernet0/0/0]ip address 192.168.3.1 24
[R4-GigabitEthernet0/0/2]ip binding vpn-instance a2
[R4-GigabitEthernet0/0/2]ip address 192.168.3.1 24
在R2和R4间搭建MP-BGP邻居
[R2]bgp 1
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 4.4.4.4 as-number 1
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R2-bgp]ipv4-family vpnv4
[R2-bgp-af-vpnv4]peer 4.4.4.4 enable
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 2.2.2.2 as-number 1
[R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R4-bgp]ipv4-family vpnv4
[R4-bgp-af-vpnv4]peer 2.2.2.2 enable
2.配置RIP和OSPF,通过BGP双向重发布学习路由,搭建MPLS VPN
[R6]rip 1
[R6-rip-1]ver 2
[R6-rip-1]network 192.168.1.0
[R6-rip-1]network 192.168.2.0
[R2]rip 1 vpn-instance a1
[R2-rip-1]ver 2
[R2-rip-1]network 192.168.2.0
[R2]rip 1 vpn-instance a1
[R2-rip-1]import-route bgp
[R2-rip-1]q
[R2]bgp 1
[R2-bgp]ipv4-family vpn-instance a1
[R2-bgp-a1]import-route rip 1
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 192.168.3.2 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 192.168.4.2 0.0.0.0
[R4]ospf 2 vpn-instance a2
[R4-ospf-2]area 0
[R4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[R4-bgp]ipv4-family vpn-instance a2
[R4-bgp-a2]import-route ospf 2
[R4-bgp-a2]q
[R4-bgp]q
[R4]ospf 2 vpn-instance a2
[R4-ospf-2]import-route bgp
3.搭建静态路由的 MPLS VPN
[R1]ip route-static 192.168.3.0 24 192.168.2.2
[R1]ip route-static 192.168.4.0 24 192.168.2.2
[R2]ip route-static vpn-instance b1 192.168.1.0 24 192.168.2.1
[R2]bgp 1
[R2-bgp]ipv4-family vpn-instance b1
[R2-bgp-b1]import-route static
[R2-bgp-b1]import-route direct
[R4]ip route-static vpn-instance b2 192.168.4.0 24 192.168.3.2
[R4]bgp 1
[R4-bgp]ipv4-family vpn-instance b2
[R4-bgp-b2]import-route static
[R4-bgp-b2]import-route direct
[R5]ip route-static 192.168.1.0 24 192.168.3.1
[R5]ip route-static 192.168.2.0 24 192.168.3.1
四、实验结果检测
全网通
VPN报表
R2
R4
R6